Java Code Examples for android.net.Uri

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AChartEngine, under directory /client/src/org/achartengine/demo/.

Source file: Demo.java

  32 
vote

@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.menu_about:
{
      Uri flickr_destination=Uri.parse(GOOGLE_CODE_URL);
      startActivity(new Intent(Intent.ACTION_VIEW,flickr_destination));
      return true;
    }
}
return super.onOptionsItemSelected(item);
}
 

Example 2

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/widget/.

Source file: SuggestionsAdapter.java

  32 
vote

public Cursor getSuggestions(String query,int limit){
  Uri.Builder uriBuilder=new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).query("").fragment("");
  uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
  uriBuilder.appendPath(query);
  if (limit > 0) {
    uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT,String.valueOf(limit));
  }
  Uri uri=uriBuilder.build();
  return mContext.getContentResolver().query(uri,null,null,null,null);
}
 

Example 3

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: BlobViewFragment.java

  32 
vote

public void displayBlob(){
  Uri data=Uri.parse("file://" + tempFile.getAbsolutePath());
  Intent intent=new Intent(android.content.Intent.ACTION_VIEW);
  intent.setDataAndType(data,mimeType);
  if (isIntentAvailable(getActivity(),intent)) {
    startActivity(intent);
  }
 else {
    Spanned messageHtml=fromHtml(getString(R.string.no_viewer_available_for_file,boldCode(nameString)));
    Toast.makeText(getActivity(),messageHtml,Toast.LENGTH_LONG).show();
  }
  getActivity().finish();
}
 

Example 4

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/helper/.

Source file: PhotoHelper.java

  32 
vote

public boolean photoExists(String path){
  if (path == null) {
    return false;
  }
  Uri uri=Uri.parse(path);
  return "http".equals(uri.getScheme()) || photoExistsLocally(path);
}
 

Example 5

From project AlarmApp-Android, under directory /src/org/alarmapp/util/.

Source file: RingtoneUtil.java

  32 
vote

public static void installRingtone(int ressourceId,String soundFile,String ringtoneName,boolean isDefaultRingtone){
  Ensure.notNull(soundFile);
  Ensure.notNull(ringtoneName);
  LogEx.verbose("Install Ringtone " + ringtoneName);
  try {
    File newSoundFile=writeToSDCard(ressourceId,soundFile);
    Uri newRingtone=installSoundFile(newSoundFile,ringtoneName);
    if (isDefaultRingtone)     setAsDefaultRingtone(newRingtone);
  }
 catch (  IOException e) {
    LogEx.exception("Failed to install the sound file " + soundFile,e);
  }
}
 

Example 6

From project android-client, under directory /xwiki-android-components/src/org/xwiki/android/components/attachments/.

Source file: AttachmentActivity.java

  32 
vote

public void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == SELECT_FILE) {
    if (resultCode == RESULT_OK) {
      Uri selectedFileUri=data.getData();
      String selectedFilePath=getPath(selectedFileUri);
      uploadFile(selectedFilePath);
    }
  }
 else   if (requestCode == VIEW_FILE) {
    currentFile.delete();
    Log.d("File delete",currentFile.getName() + " deleted");
  }
}
 

Example 7

From project android-client_1, under directory /src/com/buddycloud/view/.

Source file: PostActivity.java

  32 
vote

private void shareContent(final Intent pIntent){
  bindService(pIntent,mConnection,Context.BIND_AUTO_CREATE);
  setClickableButtons(false);
  Bundle extras=pIntent.getExtras();
  if (extras.containsKey(Intent.EXTRA_STREAM)) {
    Uri contentUri=(Uri)extras.getParcelable(Intent.EXTRA_STREAM);
    shareMediaContent(contentUri,pIntent.getType());
  }
 else   if (extras.containsKey(Intent.EXTRA_TEXT)) {
    shareTextContent(extras.getCharSequence(Intent.EXTRA_TEXT));
  }
}
 

Example 8

From project android-context, under directory /src/edu/fsu/cs/contextprovider/.

Source file: ContextAccuracyActivity.java

  32 
vote

private void setRingtone(){
  Uri ringUri;
  String ringtone=prefs.getString(ContextConstants.PREFS_ACCURACY_POPUP_AUDIO,"Default");
  if (ringtone.equalsIgnoreCase("default"))   ringUri=Settings.System.DEFAULT_RINGTONE_URI;
 else   ringUri=Uri.parse(ringtone);
  tone=RingtoneManager.getRingtone(this,ringUri);
}
 

Example 9

From project android-cropimage, under directory /src/com/android/camera/gallery/.

Source file: BaseImage.java

  32 
vote

public Bitmap fullSizeBitmap(int minSideLength,int maxNumberOfPixels,boolean rotateAsNeeded,boolean useNative){
  Uri url=mContainer.contentUri(mId);
  if (url == null)   return null;
  Bitmap b=Util.makeBitmap(minSideLength,maxNumberOfPixels,url,mContentResolver,useNative);
  if (b != null && rotateAsNeeded) {
    b=Util.rotate(b,getDegreesRotated());
  }
  return b;
}
 

Example 10

From project android-joedayz, under directory /Proyectos/client/src/org/springframework/android/showcase/social/twitter/.

Source file: TwitterWebOAuthActivity.java

  32 
vote

@Override public void onStart(){
  super.onStart();
  Uri uri=getIntent().getData();
  if (uri != null) {
    String oauthVerifier=uri.getQueryParameter("oauth_verifier");
    if (oauthVerifier != null) {
      getWebView().clearView();
      new TwitterPostConnectTask().execute(oauthVerifier);
    }
  }
 else {
    new TwitterPreConnectTask().execute();
  }
}
 

Example 11

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/model/persistence/.

Source file: AbstractEntityPersister.java

  32 
vote

@Override public Uri insert(E e){
  validate(e);
  Uri uri=mResolver.insert(getContentUri(),null);
  update(uri,e);
  FlurryAgent.onEvent(cFlurryCreateEntityEvent,mFlurryParams);
  return uri;
}
 

Example 12

From project Airports, under directory /src/com/nadmm/airports/utils/.

Source file: SystemUtils.java

  31 
vote

public static void startPDFViewer(Context context,String path){
  if (SystemUtils.canDisplayMimeType(context,MIME_TYPE_PDF)) {
    Intent viewChart=new Intent(Intent.ACTION_VIEW);
    Uri pdf=Uri.fromFile(new File(path));
    viewChart.setDataAndType(pdf,MIME_TYPE_PDF);
    context.startActivity(viewChart);
  }
 else {
    UiUtils.showToast(context,"Please install a PDF viewer app first");
    Intent market=new Intent(Intent.ACTION_VIEW);
    Uri uri=Uri.parse("market://details?id=org.ebookdroid");
    market.setData(uri);
    context.startActivity(market);
  }
}
 

Example 13

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: ContentAdapter.java

  31 
vote

public List<Date> getVersionUpdateDates(String packageName){
  List<Date> result=new ArrayList<Date>();
  if (true) {
    return result;
  }
  Uri uri=Uri.parse("content://" + AndlyticsContentProvider.AUTHORITY + "/"+ AndlyticsContentProvider.APP_VERSION_CHANGE);
  List<String> versionCodes=new ArrayList<String>();
  Cursor cursor=context.getContentResolver().query(uri,new String[]{AppStatsTable.KEY_ROWID,AppStatsTable.KEY_STATS_PACKAGENAME,AppStatsTable.KEY_STATS_DOWNLOADS,AppStatsTable.KEY_STATS_INSTALLS,AppStatsTable.KEY_STATS_COMMENTS,AppStatsTable.KEY_STATS_MARKETERANKING,AppStatsTable.KEY_STATS_CATEGORYRANKING,AppStatsTable.KEY_STATS_5STARS,AppStatsTable.KEY_STATS_4STARS,AppStatsTable.KEY_STATS_3STARS,AppStatsTable.KEY_STATS_2STARS,AppStatsTable.KEY_STATS_1STARS,AppStatsTable.KEY_STATS_REQUESTDATE,AppStatsTable.KEY_STATS_VERSIONCODE},AppStatsTable.KEY_STATS_PACKAGENAME + "='" + packageName+ "'",null,AppStatsTable.KEY_STATS_REQUESTDATE);
  if (cursor.moveToFirst()) {
    do {
      AppStats info=new AppStats();
      String dateString=cursor.getString(cursor.getColumnIndex(AppStatsTable.KEY_STATS_REQUESTDATE));
      info.setRequestDate(parseDate(dateString.substring(0,10) + " 12:00:00"));
      info.setNumberOfComments(cursor.getInt(cursor.getColumnIndex(AppStatsTable.KEY_STATS_COMMENTS)));
      info.setVersionCode(cursor.getInt(cursor.getColumnIndex(AppStatsTable.KEY_STATS_VERSIONCODE)));
      versionCodes.add(cursor.getInt(cursor.getColumnIndex(AppStatsTable.KEY_STATS_VERSIONCODE)) + "");
    }
 while (cursor.moveToNext());
  }
  cursor.close();
  Collections.sort(versionCodes);
  for (  String code : versionCodes) {
    cursor=context.getContentResolver().query(AppStatsTable.CONTENT_URI,new String[]{AppStatsTable.KEY_STATS_REQUESTDATE,AppStatsTable.KEY_STATS_VERSIONCODE},AppStatsTable.KEY_STATS_PACKAGENAME + "='" + packageName+ "' and "+ AppStatsTable.KEY_STATS_VERSIONCODE+ "="+ code,null,AppStatsTable.KEY_STATS_REQUESTDATE + " limit 1");
    if (cursor.moveToFirst()) {
      do {
        String dateString=cursor.getString(cursor.getColumnIndex(AppStatsTable.KEY_STATS_REQUESTDATE));
        result.add(parseDate(dateString.substring(0,10) + " 12:00:00"));
      }
 while (cursor.moveToNext());
    }
    cursor.close();
  }
  if (result.size() > 0) {
    result=result.subList(1,result.size());
  }
  return result;
}
 

Example 14

From project Android, under directory /AndroidNolesCore/src/io/.

Source file: ScheduleHandler.java

  31 
vote

@Override public ArrayList<ContentProviderOperation> parse(XmlPullParser parser,ContentResolver resolver) throws XmlPullParserException, IOException {
  final ArrayList<ContentProviderOperation> batch=new ArrayList<ContentProviderOperation>();
  parser.require(XmlPullParser.START_TAG,null,"feed");
  while (parser.next() != XmlPullParser.END_DOCUMENT) {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
      continue;
    }
    final String name=parser.getName();
    if ("entry".equals(name)) {
      final SpreadsheetEntry entry=SpreadsheetEntry.fromParser(parser);
      final Uri scheduleUri=Uri.withAppendedPath(mUri,Uri.encode(entry.get("title")));
      final long localUpdated=queryItemUpdated(scheduleUri,resolver);
      final long serverUpdated=entry.getUpdated();
      LOGV(TAG,"found schedule localUpdated=" + localUpdated + ", server="+ serverUpdated);
      if (localUpdated >= serverUpdated) {
        continue;
      }
      batch.add(ContentProviderOperation.newDelete(scheduleUri).build());
      final ContentProviderOperation.Builder builder=ContentProviderOperation.newInsert(mUri);
      builder.withValue("updated",serverUpdated);
      builder.withValue("date",entry.get("title"));
      builder.withValue("time",entry.get("time"));
      builder.withValue("school",entry.get("school"));
      batch.add(builder.build());
    }
  }
  return batch;
}
 

Example 15

From project android-donations-lib, under directory /org_donations/src/org/donations/.

Source file: DonationsActivity.java

  31 
vote

/** 
 * Donate button with PayPal by opening browser with defined URL For possible parameters see: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/ e_howto_html_Appx_websitestandard_htmlvariables
 * @param view
 */
public void donatePayPalOnClick(View view){
  Uri.Builder uriBuilder=new Uri.Builder();
  uriBuilder.scheme("https").authority("www.paypal.com").path("cgi-bin/webscr");
  uriBuilder.appendQueryParameter("cmd","_donations");
  uriBuilder.appendQueryParameter("business",DonationsUtils.getResourceString(this,"donations__paypal_user"));
  uriBuilder.appendQueryParameter("lc","US");
  uriBuilder.appendQueryParameter("item_name",DonationsUtils.getResourceString(this,"donations__paypal_item_name"));
  uriBuilder.appendQueryParameter("no_note","1");
  uriBuilder.appendQueryParameter("no_shipping","1");
  uriBuilder.appendQueryParameter("currency_code",DonationsUtils.getResourceString(this,"donations__paypal_currency_code"));
  Uri payPalUri=uriBuilder.build();
  if (DonationsUtils.DEBUG) {
    Log.d(DonationsUtils.TAG,"Opening the browser with the url: " + payPalUri.toString());
  }
  Intent viewIntent=new Intent(Intent.ACTION_VIEW,payPalUri);
  startActivity(viewIntent);
}
 

Example 16

From project android-share-menu, under directory /src/com/eggie5/.

Source file: post_to_eggie5.java

  31 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  Intent intent=getIntent();
  Bundle extras=intent.getExtras();
  String action=intent.getAction();
  if (Intent.ACTION_SEND.equals(action)) {
    if (extras.containsKey(Intent.EXTRA_STREAM)) {
      try {
        Uri uri=(Uri)extras.getParcelable(Intent.EXTRA_STREAM);
        ContentResolver cr=getContentResolver();
        InputStream is=cr.openInputStream(uri);
        byte[] data=getBytesFromFile(is);
        byte[] encoded_data=Base64.encodeBase64(data);
        String data_string=new String(encoded_data);
        SendRequest(data_string);
        return;
      }
 catch (      Exception e) {
        Log.e(this.getClass().getName(),e.toString());
      }
    }
 else     if (extras.containsKey(Intent.EXTRA_TEXT)) {
      return;
    }
  }
}
 

Example 17

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AAMain.java

  30 
vote

/** 
 * Opens the browser at the given URL
 * @param url - URL that we want opened in the browser
 */
private void openBrowser(Article a){
  Intent browserLaunch=new Intent();
  a.markRead();
  browserLaunch.setAction(Intent.ACTION_DEFAULT);
  browserLaunch.addCategory(Intent.CATEGORY_BROWSABLE);
  browserLaunch.setData(Uri.parse(a.getUrl()));
  this.startActivity(browserLaunch);
}
 

Example 18

From project adg-android, under directory /src/com/analysedesgeeks/android/os_service/.

Source file: PodcastPlaybackService.java

  29 
vote

public void setDataSource(final String path){
  try {
    mMediaPlayer.reset();
    mMediaPlayer.setOnPreparedListener(null);
    mMediaPlayer.setDataSource(PodcastPlaybackService.this,Uri.parse(path));
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.prepare();
  }
 catch (  final IOException ex) {
    mIsInitialized=false;
    return;
  }
catch (  final IllegalArgumentException ex) {
    mIsInitialized=false;
    return;
  }
  mMediaPlayer.setOnCompletionListener(listener);
  mMediaPlayer.setOnErrorListener(errorListener);
  mIsInitialized=true;
}
 

Example 19

From project aksunai, under directory /src/org/androidnerds/app/aksunai/service/.

Source file: ChatManager.java

  29 
vote

/** 
 * MessageListeners
 */
public void onNewMessageList(String serverName,String messageListName){
  if (AppConstants.DEBUG)   Log.d(AppConstants.CHAT_TAG,"onNewMessageList(" + serverName + ", "+ messageListName+ ")");
  mChatActivity.createChat(serverName,messageListName);
  Server s=mConnections.get(serverName);
  MessageList ml=s.mMessageLists.get(messageListName);
  ml.setOnNewMessageListener(this);
  boolean notify=mPrefs.getBoolean("pref_notification_bar",false);
  if (notify && ml.mType == MessageList.Type.PRIVATE) {
    Intent i=new Intent(this,ChatActivity.class);
    i.putExtra("server",serverName);
    i.putExtra("chat",messageListName);
    PendingIntent pending=PendingIntent.getActivity(this,0,i,0);
    Notification n=new Notification(android.R.drawable.stat_notify_chat,"New Message From " + messageListName,System.currentTimeMillis());
    n.setLatestEventInfo(this,"Aksunai","New Message From " + messageListName,pending);
    String ringtone=mPrefs.getString("notification-ringtone","");
    if (ringtone.equals("")) {
      n.defaults|=Notification.DEFAULT_SOUND;
    }
 else {
      n.sound=Uri.parse(ringtone);
    }
    if (mPrefs.getBoolean("pref_notification_vibrate",false)) {
      n.vibrate=new long[]{100,250,100,250};
    }
    mNotificationManager.notify(R.string.notify_new_private_chat,n);
  }
}
 

Example 20

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.

Source file: CreditsActivity.java

  29 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.layout_credits);
  findViewById(R.id.button_contact).setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      Intent mail=new Intent(Intent.ACTION_SENDTO);
      mail.setData(Uri.parse(String.format("mailto:%s",getString(R.string.credits_email))));
      startActivity(mail);
    }
  }
);
}
 

Example 21

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/.

Source file: AmenDetailFragmentActivity.java

  29 
vote

private void startRouteThereActivity(){
  Double lat=getCurrentStatement().getObjekt().getLat();
  Double lng=getCurrentStatement().getObjekt().getLng();
  final String uriString="http://maps.google.com" + "/maps?f=d&daddr=" + lat + ','+ lng;
  Log.d(TAG,"uriString for route: " + uriString);
  Intent showOnMapIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(uriString));
  startActivity(showOnMapIntent);
}
 

Example 22

From project android-api-demos, under directory /src/com/mobeelizer/demos/activities/.

Source file: PhotoSyncActivity.java

  29 
vote

private String getRealPathFromURI(final Uri contentUri){
  String[] proj={MediaStore.Images.Media.DATA};
  Cursor cursor=managedQuery(contentUri,proj,null,null,null);
  int column_index=cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}
 

Example 23

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: AboutActivity.java

  29 
vote

@Override public void onClick(View v){
  String tag=(String)v.getTag();
  Intent i=new Intent(Intent.ACTION_VIEW);
  if ("web".equals(tag)) {
    i.setData(Uri.parse("https://github.com/liato/android-bankdroid"));
  }
 else   if ("donate".equals(tag)) {
    i.setData(Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KWRCBB4PAA3LC"));
  }
  startActivity(i);
}
 

Example 24

From project android-database-sqlcipher, under directory /src/net/sqlcipher/.

Source file: AbstractCursor.java

  29 
vote

/** 
 * Specifies a content URI to watch for changes.
 * @param cr The content resolver from the caller's context.
 * @param notifyUri The URI to watch for changes. This can be aspecific row URI, or a base URI for a whole class of content.
 */
public void setNotificationUri(ContentResolver cr,Uri notifyUri){
synchronized (mSelfObserverLock) {
    mNotifyUri=notifyUri;
    mContentResolver=cr;
    if (mSelfObserver != null) {
      mContentResolver.unregisterContentObserver(mSelfObserver);
    }
    mSelfObserver=new SelfContentObserver(this);
    mContentResolver.registerContentObserver(mNotifyUri,true,mSelfObserver);
    mSelfObserverRegistered=true;
  }
}
 

Example 25

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: HelpManager.java

  29 
vote

@Override public void onClick(View view){
  int id=view.getId();
  Intent i=new Intent();
switch (id) {
case R.id.help_email_bt:
    i.setAction(android.content.Intent.ACTION_SEND);
  i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL,EMAIL);
try {
startActivity(Intent.createChooser(i,"Email using..."));
}
 catch (ActivityNotFoundException e) {
Toast.makeText(this,"Sorry, could not start the email",Toast.LENGTH_SHORT).show();
}
break;
case R.id.help_website_bt:
i.setAction(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse(WEB));
try {
startActivity(i);
}
 catch (ActivityNotFoundException e) {
Toast.makeText(this,"Sorry, could not open the website",Toast.LENGTH_SHORT).show();
}
break;
}
}
 

Example 26

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: EventHandler.java

  29 
vote

public void sendFile(final ArrayList<String> path){
  String name;
  CharSequence[] list={"Bluetooth","Email"};
  final String[] files=buildStringArray(path);
  final int num=path.size();
  if (num == 1)   name=path.get(0).substring(path.get(0).lastIndexOf("/") + 1,path.get(0).length());
 else   name=path.size() + " files.";
  AlertDialog.Builder b=new AlertDialog.Builder(mContext);
  b.setTitle("Sending " + name).setIcon(R.drawable.download_md).setItems(list,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
switch (which) {
case 0:
        Intent bt=new Intent(mContext,BluetoothActivity.class);
      bt.putExtra("paths",files);
    mContext.startActivity(bt);
  break;
case 1:
ArrayList<Uri> uris=new ArrayList<Uri>();
Intent mail=new Intent();
mail.setType("application/mail");
if (num == 1) {
mail.setAction(android.content.Intent.ACTION_SEND);
mail.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(files[0])));
mContext.startActivity(mail);
break;
}
for (int i=0; i < num; i++) uris.add(Uri.fromFile(new File(files[i])));
mail.setAction(android.content.Intent.ACTION_SEND_MULTIPLE);
mail.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);
mContext.startActivity(mail);
break;
}
}
}
).create().show();
}
 

Example 27

From project android-flip, under directory /FlipView/Demo/src/com/aphidmobile/flip/demo/.

Source file: FlipComplexLayoutActivity.java

  29 
vote

@Override public View getView(int position,View convertView,ViewGroup parent){
  View layout=convertView;
  if (convertView == null)   layout=inflater.inflate(R.layout.complex1,null);
  final Data data=IMG_DESCRIPTIONS.get(position);
  TextView titleView=(TextView)layout.findViewById(R.id.title);
  titleView.setText(AphidLog.format("%d. %s",position,data.title));
  ImageView photoView=(ImageView)layout.findViewById(R.id.photo);
  photoView.setImageBitmap(IO.readBitmap(inflater.getContext().getAssets(),data.imageFilename));
  TextView textView=(TextView)layout.findViewById(R.id.description);
  textView.setText(Html.fromHtml(data.description));
  Button wikipedia=(Button)layout.findViewById(R.id.wikipedia);
  wikipedia.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(data.link));
      inflater.getContext().startActivity(intent);
    }
  }
);
  return layout;
}
 

Example 28

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/.

Source file: BrowseGifsActivity.java

  29 
vote

private void shareCurrentImage(){
  String imagePath=this.mAdapter.getItemPath(this.mSS.mPosition);
  Intent intent=new Intent(Intent.ACTION_SEND);
  intent.setType("image/gif");
  intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + imagePath));
  startActivity(Intent.createChooser(intent,"ShareGif"));
}
 

Example 29

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: HelpActivity.java

  29 
vote

@Override public boolean shouldOverrideUrlLoading(WebView view,String url){
  if (url.startsWith("file")) {
    return false;
  }
 else   if (url.startsWith("mailto:")) {
    try {
      MailTo mt=MailTo.parse(url);
      Intent i=new Intent(Intent.ACTION_SEND);
      i.setType("message/rfc822");
      i.putExtra(Intent.EXTRA_EMAIL,new String[]{mt.getTo()});
      i.putExtra(Intent.EXTRA_SUBJECT,mt.getSubject());
      context.startActivity(i);
      view.reload();
    }
 catch (    ActivityNotFoundException e) {
      Log.w(TAG,"Problem with Intent.ACTION_SEND",e);
      new AlertDialog.Builder(context).setTitle("Contact Info").setMessage("Please send your feedback to: app.ocr@gmail.com").setPositiveButton("Done",new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          Log.d("AlertDialog","Positive");
        }
      }
).show();
    }
    return true;
  }
 else {
    startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(url)));
    return true;
  }
}
 

Example 30

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: ContactActivity.java

  29 
vote

private void setUpButtons(){
  Button usButton=(Button)findViewById(R.id.contact_us_button);
  usButton.setText(USNUMBER);
  usButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      String phone="tel:" + USNUMBER;
      Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phone));
      startActivity(i);
    }
  }
);
  Button ukButton=(Button)findViewById(R.id.contact_uk_button);
  ukButton.setText(UKNUMBER);
  ukButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      String phone="tel:" + UKNUMBER;
      Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phone));
      startActivity(i);
    }
  }
);
  Button twitterButton=(Button)findViewById(R.id.contact_twitter_button);
  twitterButton.setText(twitterAddress);
  twitterButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      Log.d("info","http://" + twitterAddress);
      Intent browse=new Intent(Intent.ACTION_VIEW,Uri.parse("http://mobile.twitter.com/rackspace"));
      startActivity(browse);
    }
  }
);
}
 

Example 31

From project android-rss, under directory /src/test/java/org/mcsoxford/rss/.

Source file: RSSParserTest.java

  29 
vote

@Test public void parse() throws Exception {
  final RSSFeed feed=parse(stream);
  assertEquals("Example Channel",feed.getTitle());
  assertEquals(Uri.parse("http://example.com/"),feed.getLink());
  assertEquals("My example channel",feed.getDescription());
  final Iterator<RSSItem> items=feed.getItems().iterator();
  RSSItem item;
  item=items.next();
  assertEquals("News for November",item.getTitle());
  assertEquals(Uri.parse("http://example.com/2010/11/07"),item.getLink());
  assertEquals("Other things happened today",item.getDescription());
  assertTrue(item.getCategories().isEmpty());
  GregorianCalendar calendar=new GregorianCalendar(2010,10,07,8,22,14);
  calendar.setTimeZone(TimeZone.getTimeZone("Etc/GMT"));
  Date expectedDate=calendar.getTime();
  assertEquals(expectedDate,item.getPubDate());
  assertEquals(2,item.getThumbnails().size());
  MediaThumbnail expectedThumbnail0=new MediaThumbnail(Uri.parse("http://example.com/media/images/12/jpg/_7_2.jpg"),49,66);
  assertEquals(expectedThumbnail0.getUrl(),item.getThumbnails().get(0).getUrl());
  assertEquals(expectedThumbnail0.getHeight(),item.getThumbnails().get(0).getHeight());
  assertEquals(expectedThumbnail0.getWidth(),item.getThumbnails().get(0).getWidth());
  MediaThumbnail expectedThumbnail1=new MediaThumbnail(Uri.parse("http://example.com/media/images/12/jpg/_7_2-1.jpg"),81,144);
  assertEquals(expectedThumbnail1.getUrl(),item.getThumbnails().get(1).getUrl());
  assertEquals(expectedThumbnail1.getHeight(),item.getThumbnails().get(1).getHeight());
  assertEquals(expectedThumbnail1.getWidth(),item.getThumbnails().get(1).getWidth());
  item=items.next();
  assertEquals("News for October",item.getTitle());
  assertEquals(Uri.parse("http://example.com/2010/10/12"),item.getLink());
  assertEquals("October days: we&#8217;re, <b>apple</b> ##<i>pie</i>",item.getDescription());
  assertEquals("October days: we&#8217;re, <b>apple</b> ##<i>pie</i>",item.getContent());
  assertEquals(2,item.getCategories().size());
  assertTrue(item.getCategories().contains("Daily news"));
  assertTrue(item.getCategories().contains("October news"));
  assertEquals(0,item.getThumbnails().size());
  assertFalse(items.hasNext());
}