List of usage examples for android.content Intent CATEGORY_BROWSABLE
String CATEGORY_BROWSABLE
To view the source code for android.content Intent CATEGORY_BROWSABLE.
Click Source Link
From source file:com.xortech.sender.SenderMain.java
/** * Handle menu options item selected/*from w w w. j av a2s. c o m*/ * */ @SuppressWarnings("deprecation") @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.quit: MyUpdateReceiver.trimCache(this); System.exit(0); return true; case R.id.rateApp: // CHANGE PREFERENCES TO NEVER SHOW AGAIN SharedPreferences prefs = getSharedPreferences("apprater", 0); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("dontshowagain", true); editor.commit(); try { Intent rateApp = new Intent(Intent.ACTION_VIEW); rateApp.setData(Uri.parse("market://details?id=com.xortech.sender")); startActivity(rateApp); } catch (Exception e) { Log.e("Error launching apprater: ", "" + e); } return true; case R.id.tagsApp: try { Intent myTagIntent = new Intent(this, TagAddMain.class); startActivity(myTagIntent); } catch (Exception e) { Log.e("Error launching mytags: ", "" + e); } return true; case R.id.panicApp: try { Intent myPanicIntent = new Intent(this, PanicAddMain.class); startActivity(myPanicIntent); } catch (Exception e) { Log.e("Error launching panic: ", "" + e); } return true; case R.id.donateApp: try { Intent upIntent = new Intent(); upIntent.setAction(Intent.ACTION_VIEW); upIntent.addCategory(Intent.CATEGORY_BROWSABLE); upIntent.setData(Uri.parse("https://coinbase.com/checkouts/4bc224c6764e7908bea274c12badce5e")); startActivity(upIntent); } catch (Exception e) { Log.e("Error launching donate: ", "" + e); } return true; case android.R.id.home: Intent upIntent = NavUtils.getParentActivityIntent(this); if (NavUtils.shouldUpRecreateTask(this, upIntent)) { TaskStackBuilder.create(this) // ADD ALL THE PARENTS TO THE BACKSTACK .addNextIntentWithParentStack(upIntent) // NAVIGATE UP TO THE CLOSEST PARENT .startActivities(); } else { // NAVIGATE UP TO THE LOGICAL PARENT ACTIVITY NavUtils.navigateUpTo(this, upIntent); } return true; case R.id.action_settings: showDialog(DIALOG_ASK_PASSWORD); } return true; }
From source file:com.airbop.client.GCMIntentService.java
private static void generateNotification(Context context, String title, String message, String url, String large_icon) {/* w w w . j a va 2 s . com*/ int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if ((title == null) || (title.equals(""))) { title = context.getString(R.string.app_name); } Intent notificationIntent = null; if ((url == null) || (url.equals(""))) { //just bring up the app notificationIntent = new Intent(context, DemoActivity.class); } else { //Launch the URL notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setData(Uri.parse(url)); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); } // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(intent).setSmallIcon(icon) .setLargeIcon(decodeImage(large_icon)).setWhen(when) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.ohso.omgubuntu.BaseFragment.java
@Override public void onClick(View v) { footerView.setEnabled(false);/* www .j a v a 2s .c om*/ if (nextPageAllowed && currentPage < MAXIMUM_PAGED) { ((TextView) v).setText(getResources().getString(R.string.loading_text)); if (refresh != null) refresh.setActionView(R.layout.refresh_menu_item); getNextPage(); } else { Intent external = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.base_url))); external.addCategory(Intent.CATEGORY_BROWSABLE); Intent chooser = Intent.createChooser(external, getResources().getString(R.string.activity_main_footer_dialog)); startActivity(chooser); } }
From source file:org.mariotaku.gallery3d.ImageViewerGLActivity.java
@Override public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case MENU_SAVE: { if (mImageFile != null) { new SaveImageTask(this, mImageFile).execute(); }/*from www . j av a 2s .co m*/ break; } case MENU_OPEN_IN_BROWSER: { final Intent intent = getIntent(); intent.setExtrasClassLoader(getClassLoader()); final Uri uri = intent.getData(); final Uri orig = intent.getParcelableExtra(EXTRA_URI_ORIG); final Uri uriPreferred = orig != null ? orig : uri; if (uriPreferred == null) return false; final String scheme = uriPreferred.getScheme(); if ("http".equals(scheme) || "https".equals(scheme)) { final Intent open_intent = new Intent(Intent.ACTION_VIEW, uriPreferred); open_intent.addCategory(Intent.CATEGORY_BROWSABLE); try { startActivity(open_intent); } catch (final ActivityNotFoundException e) { // Ignore. } } break; } default: { final Intent intent = item.getIntent(); if (intent != null) { try { startActivity(intent); } catch (final ActivityNotFoundException e) { // Ignore. } return true; } return false; } } return true; }
From source file:com.mobage.android.shellappsdk.sample.GameWebView.java
private boolean handleExternalDomainUrl(String url) { Uri uri = Uri.parse(url);/*from w w w . jav a 2 s.com*/ String host = uri.getHost(); if (mDomainWhiteList.containsHost(host)) { return false; } // No match - Sending Intent to External Browser if ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (getContext() instanceof Activity) { getContext().startActivity(intent); } } return true; }
From source file:com.google.android.apps.muzei.datalayer.ActivateMuzeiIntentService.java
@Override protected void onHandleIntent(Intent intent) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String action = intent.getAction(); if (TextUtils.equals(action, ACTION_MARK_NOTIFICATION_READ)) { preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); return;/*from w w w.jav a 2 s . c o m*/ } else if (TextUtils.equals(action, ACTION_REMOTE_INSTALL_MUZEI)) { Intent remoteIntent = new Intent(Intent.ACTION_VIEW).addCategory(Intent.CATEGORY_BROWSABLE) .setData(Uri.parse("market://details?id=" + getPackageName())); RemoteIntent.startRemoteActivity(this, remoteIntent, new ResultReceiver(new Handler()) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { if (resultCode == RemoteIntent.RESULT_OK) { FirebaseAnalytics.getInstance(ActivateMuzeiIntentService.this) .logEvent("activate_notif_install_sent", null); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); } else { Toast.makeText(ActivateMuzeiIntentService.this, R.string.activate_install_failed, Toast.LENGTH_SHORT).show(); } } }); return; } // else -> Open on Phone action GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build(); ConnectionResult connectionResult = googleApiClient.blockingConnect(30, TimeUnit.SECONDS); if (!connectionResult.isSuccess()) { Log.e(TAG, "Failed to connect to GoogleApiClient."); Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); return; } Set<Node> nodes = Wearable.CapabilityApi .getCapability(googleApiClient, "activate_muzei", CapabilityApi.FILTER_REACHABLE).await() .getCapability().getNodes(); if (nodes.isEmpty()) { Toast.makeText(this, R.string.activate_failed, Toast.LENGTH_SHORT).show(); } else { FirebaseAnalytics.getInstance(this).logEvent("activate_notif_message_sent", null); // Show the open on phone animation Intent openOnPhoneIntent = new Intent(this, ConfirmationActivity.class); openOnPhoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); openOnPhoneIntent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION); startActivity(openOnPhoneIntent); // Clear the notification NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(INSTALL_NOTIFICATION_ID); preferences.edit().putBoolean(ACTIVATE_MUZEI_NOTIF_SHOWN_PREF_KEY, true).apply(); // Send the message to the phone to open Muzei for (Node node : nodes) { Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), "notification/open", null).await(); } } googleApiClient.disconnect(); }
From source file:org.apache.cordova.CordovaWebViewImpl.java
@Override public void showWebPage(String url, boolean openExternal, boolean clearHistory, Map<String, Object> params) { LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap)", url, openExternal, clearHistory); // If clearing history if (clearHistory) { engine.clearHistory();//from w w w .ja va 2 s .c om } // If loading into our webview if (!openExternal) { // Make sure url is in whitelist if (pluginManager.shouldAllowNavigation(url)) { // TODO: What about params? // Load new URL loadUrlIntoView(url, true); } else { LOG.w(TAG, "showWebPage: Refusing to load URL into webview since it is not in the <allow-navigation> whitelist. URL=" + url); } } if (!pluginManager.shouldOpenExternalUrl(url)) { LOG.w(TAG, "showWebPage: Refusing to send intent for URL since it is not in the <allow-intent> whitelist. URL=" + url); return; } try { Intent intent = new Intent(Intent.ACTION_VIEW); // To send an intent without CATEGORY_BROWSER, a custom plugin should be used. intent.addCategory(Intent.CATEGORY_BROWSABLE); Uri uri = Uri.parse(url); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, resourceApi.getMimeType(uri)); } else { intent.setData(uri); } cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } }
From source file:net.openid.appauthdemo.Configuration.java
private boolean isRedirectUriRegistered() { // ensure that the redirect URI declared in the configuration is handled by some activity // in the app, by querying the package manager speculatively Intent redirectIntent = new Intent(); redirectIntent.setPackage(mContext.getPackageName()); redirectIntent.setAction(Intent.ACTION_VIEW); redirectIntent.addCategory(Intent.CATEGORY_BROWSABLE); redirectIntent.setData(mRedirectUri); return !mContext.getPackageManager().queryIntentActivities(redirectIntent, 0).isEmpty(); }
From source file:org.mariotaku.twidere.activity.MediaViewerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final ViewPager viewPager = findViewPager(); final PagerAdapter adapter = viewPager.getAdapter(); final int currentItem = viewPager.getCurrentItem(); if (currentItem < 0 || currentItem >= adapter.getCount()) return false; final Object object = adapter.instantiateItem(viewPager, currentItem); if (!(object instanceof MediaViewerFragment)) return false; switch (item.getItemId()) { case R.id.refresh: { if (object instanceof CacheDownloadMediaViewerFragment) { final CacheDownloadMediaViewerFragment fragment = (CacheDownloadMediaViewerFragment) object; fragment.startLoading(true); fragment.showProgress(true, 0); fragment.setMediaViewVisible(false); }/* w w w. j a va2s.c o m*/ return true; } case R.id.share: { if (object instanceof CacheDownloadMediaViewerFragment) { requestAndShareMedia(currentItem); } else { final ParcelableMedia media = getMedia()[currentItem]; final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, media.url); startActivity(Intent.createChooser(intent, getString(R.string.share))); } return true; } case R.id.save: { requestAndSaveToStorage(currentItem); return true; } case R.id.open_in_browser: { final ParcelableMedia media = getMedia()[currentItem]; try { final Uri uri = Uri.parse(media.url); final Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setPackage(IntentUtils.getDefaultBrowserPackage(this, uri, true)); startActivity(intent); } catch (ActivityNotFoundException e) { // TODO show error, or improve app url } return true; } case android.R.id.home: { finish(); return true; } } return super.onOptionsItemSelected(item); }
From source file:de.flyingsnail.ipv6droid.android.MainActivity.java
private void openHelp() { Intent helpIntent = new Intent(Intent.ACTION_VIEW); helpIntent.setDataAndType(Uri.parse("https://sourceforge.net/p/ipv6droid/wiki/Home/"), "text/html"); helpIntent.addCategory(Intent.CATEGORY_BROWSABLE); startActivity(helpIntent);/*from w w w .j av a 2 s .c o m*/ }