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:com.elkriefy.android.apps.chubbytabby.CustomTabsHelper.java
/** * Goes through all apps that handle VIEW intents and have a warmup service. Picks the one * chosen by the user if there is one, otherwise makes a best effort to return a valid package * name.// ww w . j av a2 s. co m * * This is <strong>not</strong> threadsafe. * * @param context {@link Context} to use for accessing {@link PackageManager}. * @return The package name recommended to use for connecting to custom tabs related components. */ public static String getPackageNameToUse(Context context) { if (sPackageNameToUse != null) return sPackageNameToUse; PackageManager pm = context.getPackageManager(); // Get default VIEW intent handler. Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.packtpub.com")); ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0); String defaultViewHandlerPackageName = null; if (defaultViewHandlerInfo != null) { defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName; } // Get all apps that can handle VIEW intents. List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0); List<String> packagesSupportingCustomTabs = new ArrayList<>(); for (ResolveInfo info : resolvedActivityList) { Intent serviceIntent = new Intent(); serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION); serviceIntent.setPackage(info.activityInfo.packageName); if (pm.resolveService(serviceIntent, 0) != null) { packagesSupportingCustomTabs.add(info.activityInfo.packageName); } } // Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents // and service calls. if (packagesSupportingCustomTabs.isEmpty()) { sPackageNameToUse = null; } else if (packagesSupportingCustomTabs.size() == 1) { sPackageNameToUse = packagesSupportingCustomTabs.get(0); } else if (!android.text.TextUtils.isEmpty(defaultViewHandlerPackageName) && !hasSpecializedHandlerIntents(context, activityIntent) && packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) { sPackageNameToUse = defaultViewHandlerPackageName; } else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) { sPackageNameToUse = STABLE_PACKAGE; } else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) { sPackageNameToUse = BETA_PACKAGE; } else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) { sPackageNameToUse = DEV_PACKAGE; } else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) { sPackageNameToUse = LOCAL_PACKAGE; } return sPackageNameToUse; }
From source file:Main.java
/** * Open banking App for given context and secure token. Use this method if you do not use the Pay by Bank app Popup API (which takes care of the banking app * opening)./*from w w w . j a v a 2 s. c o m*/ * * @param context The (activity or application) context to start the banking App. * @param secureToken The secure token of the payment for which the banking App is to be started. * @see #isCFIAppAvailable(Context) * @see #showPBBAPopup(FragmentActivity, String, String, PBBAPopupCallback) * @see #showPBBAErrorPopup(FragmentActivity, String, String, String, PBBAPopupCallback) */ public static void openBankingApp(@NonNull Context context, @NonNull final String secureToken) { //noinspection ConstantConditions if (context == null) { throw new IllegalArgumentException("context == null"); } if (TextUtils.isEmpty(secureToken)) { throw new IllegalArgumentException("secureToken is required"); } final Uri zappUri = Uri.parse(String.format(ZAPP_URI_FORMAT_STRING, ZAPP_SCHEME, secureToken)); final Intent bankingAppStartIntent = new Intent(Intent.ACTION_VIEW, zappUri); @SuppressWarnings("BooleanVariableAlwaysNegated") final boolean isActivityContext = context instanceof Activity; if (!isActivityContext) { bankingAppStartIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(bankingAppStartIntent); }
From source file:net.reichholf.dreamdroid.intents.IntentFactory.java
public static Intent getStreamFileIntent(String fileName, String title) { Intent intent = new Intent(Intent.ACTION_VIEW); SimpleHttpClient shc = SimpleHttpClient.getInstance(); ArrayList<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("file", fileName)); Uri uri = Uri.parse(shc.buildFileStreamUrl(URIStore.FILE, params)); Log.i(DreamDroid.LOG_TAG, "Streaming file: " + uri.getEncodedQuery()); intent.setDataAndType(uri, "video/*"); intent.putExtra("title", title); return intent; }
From source file:com.app.common.util.IntentUtils.java
public static void startWebActivity(Context context, String url) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url));//from w w w . j av a 2 s.c o m context.startActivity(intent); }
From source file:com.gsoc.ijosa.liquidgalaxycontroller.PW.Utils.java
public static Intent createNavigateToUrlIntent(PwsResult pwsResult) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(pwsResult.getSiteUrl())); return intent; }
From source file:com.ihelpoo.app.common.QQWeiboHelper.java
/** * ?/*from ww w . j a va 2s. c o m*/ * @param activity * @param title * @param url */ public static void shareToQQ(Activity activity, String title, String url) { String URL = Share_URL; try { URL += "&title=" + URLEncoder.encode(title, HTTP.UTF_8) + "&url=" + URLEncoder.encode(url, HTTP.UTF_8) + "&appkey=" + Share_AppKey + "&source=" + Share_Source + "&site=" + Share_Site; } catch (Exception e) { e.printStackTrace(); } Uri uri = Uri.parse(URL); activity.startActivity(new Intent(Intent.ACTION_VIEW, uri)); }
From source file:com.github.longkai.zhihu.util.Utils.java
/** * view user' s infomation on the web./*from w w w. j a v a2 s . c o m*/ * * @param context * @param id */ public static void viewUserInfo(Context context, String id) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.zhihu.com/people/" + id)); context.startActivity(intent); }
From source file:net.eledge.android.europeana.gui.notification.receiver.UrlButtonReceiver.java
@Override public void onReceive(Context context, Intent intent) { int notificationId = intent.getIntExtra(PARAM_NOTIFICATIONID, Config.NOTIFICATION_NEWBLOG); String url = intent.getStringExtra(PARAM_URL); if (StringUtils.isNoneBlank(url)) { try {//from www .j a v a 2s. com PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse(url)), PendingIntent.FLAG_UPDATE_CURRENT).send(); } catch (PendingIntent.CanceledException e) { Log.e(UrlButtonReceiver.class.getSimpleName(), e.getMessage(), e); } } final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); }
From source file:com.diusrex.update.Update.java
public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException { Activity activity = this.cordova.getActivity(); final String appPackageName = activity.getPackageName(); try {// w w w . j ava2 s . c o m activity.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } boolean quitApp = args.getBoolean(0); if (quitApp) { activity.finish(); } return true; }
From source file:com.github.fi3te.iliasdownloader.controller.Util.java
public static void openFile(File file, Activity forMessages) { if (file != null && forMessages != null && file.isFile()) { String extension = FilenameUtils.getExtension(file.getPath()); if (extension.length() > 0) { try { extension = extension.toLowerCase(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); forMessages.startActivity(intent); } catch (ActivityNotFoundException anfe) { Toast.makeText(forMessages, forMessages.getResources().getString(R.string.unknown_type), Toast.LENGTH_SHORT).show(); }/*from w w w. jav a 2s. c o m*/ } } }