List of usage examples for android.content Intent ACTION_VIEW
String ACTION_VIEW
To view the source code for android.content Intent ACTION_VIEW.
Click Source Link
From source file:de.grobox.blitzmail.NotificationHandlerActivity.java
@Override protected void onNewIntent(Intent intent) { Bundle extras = intent.getExtras();/* w ww.ja v a2s.c o m*/ // show dialog for server errors if (extras != null && extras.getString("ContentTitle").equals(getString(R.string.error))) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + " - " + getString(R.string.error)); builder.setMessage(extras.getString("ContentText")); builder.setIcon(android.R.drawable.ic_dialog_alert); // Add the buttons builder.setNegativeButton(getResources().getString(R.string.dismiss), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { deleteMail(); // User clicked Cancel button, close this Activity finish(); } }); builder.setNeutralButton(getResources().getString(R.string.send_later), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked Cancel button if (BuildConfig.PRO) { // close this Activity finish(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(getString(R.string.app_name)); builder.setMessage(getString(R.string.error_lite_version)); builder.setIcon(android.R.drawable.ic_dialog_info); // Add the buttons builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface lite_dialog, int id) { Uri uri = Uri.parse( "https://play.google.com/store/apps/details?id=de.grobox.blitzmail.pro"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } lite_dialog.dismiss(); finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface lite_dialog, int id) { lite_dialog.dismiss(); finish(); } }); // Create and show the AlertDialog AlertDialog lite_dialog = builder.create(); lite_dialog.setCanceledOnTouchOutside(false); lite_dialog.show(); } } }); builder.setPositiveButton(getResources().getString(R.string.try_again), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Prepare start of new activity Intent intent = new Intent(context, SendActivity.class); intent.setAction("BlitzMailReSend"); intent.putExtra("mail", mMail.toString()); finish(); startActivity(intent); } }); // Create and show the AlertDialog AlertDialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); } else { // close activity finish(); } }
From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java
private void launchBrowserTask(Context context, String url, String packageName) { Log.v(C.TAG, "launchBrowserTask"); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setPackage(packageName); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); List<ResolveInfo> activitiesList = context.getPackageManager().queryIntentActivities(browserIntent, -1); if (activitiesList.size() > 0) { browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); context.startActivity(browserIntent); } else {/* w w w . ja v a 2s . c o m*/ Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); playStoreIntent.setData(Uri.parse("market://details?id=" + packageName)); playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(playStoreIntent); /**Intent rawIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); rawIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(rawIntent);**/ } }
From source file:com.menumomma.chrome2phone.C2DMReceiver.java
@Override public void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras();// w w w .j ava2 s. c o m if (extras != null) { String url = (String) extras.get("url"); String title = (String) extras.get("title"); String sel = (String) extras.get("sel"); String debug = (String) extras.get("debug"); if (debug != null) { // server-controlled debug - the server wants to know // we received the message, and when. This is not user-controllable, // we don't want extra traffic on the server or phone. Server may // turn this on for a small percentage of requests or for users // who report issues. DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(Config.BASE_URL + "/debug?id=" + extras.get("collapse_key")); // No auth - the purpose is only to generate a log/confirm delivery // (to avoid overhead of getting the token) try { client.execute(get); } catch (ClientProtocolException e) { // ignore } catch (IOException e) { // ignore } } if (title != null && url != null && url.startsWith("http")) { SharedPreferences settings = Prefs.get(context); Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel); // Notify and optionally start activity if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) { try { context.startActivity(launchIntent); LauncherUtils.playNotificationSound(context); } catch (ActivityNotFoundException e) { return; } } else { LauncherUtils.generateNotification(context, url, title, launchIntent); } // Record history (for link/maps only) if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) { HistoryDatabase.get(context).insertHistory(title, url); } } } }
From source file:com.codeskraps.lolo.misc.Utils.java
public static PendingIntent getOnTouchIntent(Context context) { PendingIntent pendingIntent = null;// w ww . j a v a 2s .c o m Intent intent = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int onClick = Integer.parseInt(prefs.getString(Constants.ONCLICK, "0")); switch (onClick) { case 0: intent = new Intent("com.codeskraps.lol.DO_NOTHING"); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 1: intent = new Intent(context, TweetsFeedActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 2: intent = new Intent(); intent.setAction(Constants.BROADCAST_RECEIVER); pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 3: intent = new Intent(context, PrefsActivity.class); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; case 4: intent = new Intent(Intent.ACTION_VIEW); String url = prefs.getString(Constants.EURL, context.getString(R.string.prefsURL_default)); if (!url.startsWith("http://")) url = "http://" + url; intent.setData(Uri.parse(url)); pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); break; } return pendingIntent; }
From source file:com.browsertophone.C2DMReceiver.java
@Override public void onMessage(Context context, Intent intent) { Bundle extras = intent.getExtras();/*from www .j av a 2 s. co m*/ if (extras != null) { String url = (String) extras.get("url"); String title = (String) extras.get("title"); String sel = (String) extras.get("sel"); String debug = (String) extras.get("debug"); if (debug != null) { // server-controlled debug - the server wants to know // we received the message, and when. This is not user-controllable, // we don't want extra traffic on the server or phone. Server may // turn this on for a small percentage of requests or for users // who report issues. DefaultHttpClient client = new DefaultHttpClient(); HttpGet get = new HttpGet(AppEngineClient.BASE_URL + "/debug?id=" + extras.get("collapse_key")); // No auth - the purpose is only to generate a log/confirm delivery // (to avoid overhead of getting the token) try { client.execute(get); } catch (ClientProtocolException e) { // ignore } catch (IOException e) { // ignore } } if (title != null && url != null && url.startsWith("http")) { SharedPreferences settings = Prefs.get(context); Intent launchIntent = LauncherUtils.getLaunchIntent(context, title, url, sel); // Notify and optionally start activity if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) { LauncherUtils.playNotificationSound(context); context.startActivity(launchIntent); } else { if (sel != null && sel.length() > 0) { // have selection LauncherUtils.generateNotification(context, sel, context.getString(R.string.copied_desktop_clipboard), launchIntent); } else { LauncherUtils.generateNotification(context, url, title, launchIntent); } } // Record history (for link/maps only) if (launchIntent != null && launchIntent.getAction().equals(Intent.ACTION_VIEW)) { HistoryDatabase.get(context).insertHistory(title, url); } } } }
From source file:mobisocial.socialkit.musubi.Musubi.java
public static Intent getMarketIntent() { Uri marketUri = Uri.parse("market://details?id=" + SUPER_APP_ID); return new Intent(Intent.ACTION_VIEW, marketUri); }
From source file:com.qrcode.app.zxing.decoding.CaptureActivityHandler.java
@Override public void handleMessage(Message message) { switch (message.what) { case R.id.auto_focus: //Log.d(TAG, "Got auto-focus message"); // When one auto focus pass finishes, start another. This is the closest thing to // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do. if (state == State.PREVIEW) { CameraManager.get().requestAutoFocus(this, R.id.auto_focus); }/*from w ww .j a va 2 s . c o m*/ break; case R.id.restart_preview: Log.d(TAG, "Got restart preview message"); restartPreviewAndDecode(); break; case R.id.decode_succeeded: Log.d(TAG, "Got decode succeeded message"); state = State.SUCCESS; Bundle bundle = message.getData(); /***********************************************************************/ Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//?????????? try { activity.handleDecode((Result) message.obj, barcode);//??????? /***********************************************************************/ } catch (JSONException e) { e.printStackTrace(); } break; case R.id.decode_failed: // We're decoding as fast as possible, so when one decode fails, start another. state = State.PREVIEW; CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); break; case R.id.return_scan_result: Log.d(TAG, "Got return scan result message"); activity.setResult(Activity.RESULT_OK, (Intent) message.obj); activity.finish(); break; case R.id.launch_product_query: Log.d(TAG, "Got product query message"); String url = (String) message.obj; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); break; } }
From source file:it.feio.android.omninotes.async.UpdaterTask.java
private void promptUpdate() { // Confirm dialog creation final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivityReference.get()); alertDialogBuilder.setCancelable(false).setMessage(R.string.new_update_available) .setPositiveButton(R.string.update, new DialogInterface.OnClickListener() { @Override/*from ww w . j av a2s .c o m*/ public void onClick(DialogInterface dialog, int id) { if (isGooglePlayAvailable()) { mActivityReference.get().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName))); } else { // MapBuilder.createEvent().build() returns a Map of event fields and values // that are set and sent with the hit. OmniNotes.getGaTracker().send(MapBuilder.createEvent("ui_action", // Event category (required) "button_press", // Event action (required) "Google Drive Update", // Event label null) // Event value .build()); mActivityReference.get().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.DRIVE_FOLDER_LAST_BUILD))); } dialog.dismiss(); } }).setNegativeButton(R.string.not_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:net.reichholf.dreamdroid.activities.DreamDroidShareActivity.java
@SuppressWarnings("deprecation") private void playOnDream(Profile p) { String url = null;//from w w w .ja va 2 s .c o m Intent i = getIntent(); Bundle extras = i.getExtras(); mShc = SimpleHttpClient.getInstance(p); if (Intent.ACTION_SEND.equals(i.getAction())) url = extras.getString(Intent.EXTRA_TEXT); else if (Intent.ACTION_VIEW.equals(i.getAction())) url = i.getDataString(); if (url != null) { Log.i(LOG_TAG, url); Log.i(LOG_TAG, p.getHost()); String time = DateFormat.getDateFormat(this).format(new Date()); String title = getString(R.string.sent_from_dreamdroid, time); if (extras != null) { // semperVidLinks sends "artist" and "song" attributes for the // youtube video titles String song = extras.getString("song"); if (song != null) { String artist = extras.getString("artist"); if (artist != null) title = artist + " - " + song; } else { String tmp = extras.getString("title"); if (tmp != null) title = tmp; } } mTitle = new String(title); url = URLEncoder.encode(url).replace("+", "%20"); title = URLEncoder.encode(title).replace("+", "%20"); String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title; Log.i(LOG_TAG, ref); ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("file", ref)); execSimpleResultTask(params); } else { finish(); } }
From source file:com.krayzk9s.imgurholo.services.UploadService.java
public void onGetObject(Object o, String tag) { String id = (String) o; if (id.length() == 7) { if (totalUpload != -1) ids.add(id);// w ww .ja v a2 s . c om if (ids.size() == totalUpload) { ids.add(0, ""); //weird hack because imgur eats the first item of the array for some bizarre reason NewAlbumAsync newAlbumAsync = new NewAlbumAsync("", "", apiCall, ids, this); newAlbumAsync.execute(); } } else if (apiCall.settings.getBoolean("AlbumUpload", true)) { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Intent viewImageIntent = new Intent(); viewImageIntent.setAction(Intent.ACTION_VIEW); viewImageIntent.setData(Uri.parse("http://imgur.com/a/" + id)); Intent shareIntent = new Intent(); shareIntent.setType("text/plain"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareIntent.putExtra(Intent.EXTRA_TEXT, "http://imgur.com/a/" + id); PendingIntent viewImagePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), viewImageIntent, 0); PendingIntent sharePendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), shareIntent, 0); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading Album").setContentTitle("imgur Image Uploader") .setContentIntent(viewImagePendingIntent) .addAction(R.drawable.dark_social_share, "Share", sharePendingIntent).build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } else { NotificationManager notificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); Notification notification = notificationBuilder.setSmallIcon(R.drawable.icon_desaturated) .setContentText("Finished Uploading All Images").setContentTitle("imgur Image Uploader") .build(); Log.d("Built", "Notification built"); notificationManager.cancel(0); notificationManager.notify(1, notification); Log.d("Built", "Notification display"); } }