private int queryActiviesNumber(String url) { try { if (mWeakReference.get() == null) { return 0; } Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); PackageManager mPackageManager = mWeakReference.get().getPackageManager(); List<ResolveInfo> mResolveInfos = mPackageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return mResolveInfos == null ? 0 : mResolveInfos.size(); } catch (URISyntaxException ignore) { if (LogUtils.isDebug()) { ignore.printStackTrace(); } return 0; } }
private boolean lookup(String url) { try { Intent intent; Activity mActivity = null; if ((mActivity = mWeakReference.get()) == null) { return true; } PackageManager packageManager = mActivity.getPackageManager(); intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); ResolveInfo info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); // 跳到该应用 if (info != null) { mActivity.startActivity(intent); return true; } } catch (Throwable ignore) { if (LogUtils.isDebug()) { ignore.printStackTrace(); } } return false; }
try { if (url.startsWith("intent:")) { intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); } else if (url.startsWith("android-app:")) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { intent = Intent.parseUri(url, 0); intent.setData(null); intent.setPackage(Uri.parse(url).getHost()); } else { intent = Intent.parseUri(url, Intent.URI_ANDROID_APP_SCHEME);
/** * Deserializes a {@link Bundle} into a {@link Action} object. */ public static Action fromBundle(Bundle bundle) { String title = bundle.getString(KEY_TITLE); if (TextUtils.isEmpty(title)) { return null; } int entityIdentifier = bundle.getInt(KEY_ENTITY_IDENTIFIER); if (entityIdentifier <= 0) { return null; } Builder builder = new Builder(title, entityIdentifier); try { String viewIntent = bundle.getString(KEY_VIEW_INTENT); if (!TextUtils.isEmpty(viewIntent)) { builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME)); } } catch (URISyntaxException ignored) { } return builder.build(); }
/** * Deserializes a {@link JSONObject} into an {@link Action} object. */ public static Action fromJson(JSONObject jsonObject) throws JSONException { String title = jsonObject.optString(KEY_TITLE); if (TextUtils.isEmpty(title)) { return null; } int entityIdentifier = jsonObject.optInt(KEY_ENTITY_IDENTIFIER); if (entityIdentifier <= 0) { return null; } Builder builder = new Builder(title, entityIdentifier); try { String viewIntent = jsonObject.optString(KEY_VIEW_INTENT); if (!TextUtils.isEmpty(viewIntent)) { builder.viewIntent(Intent.parseUri(viewIntent, Intent.URI_INTENT_SCHEME)); } } catch (URISyntaxException ignored) { } return builder.build(); } }
@Override protected void doLaunch(Context context, View v) { if (shortcutPojo.isOreoShortcut()) { // Oreo shortcuts doOreoLaunch(context, v); } else { // Pre-oreo shortcuts try { Intent intent = Intent.parseUri(shortcutPojo.intentUri, 0); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { intent.setSourceBounds(v.getClipBounds()); } context.startActivity(intent); } catch (Exception e) { // Application was just removed? Toast.makeText(context, R.string.application_not_found, Toast.LENGTH_LONG).show(); } } }
Drawable appDrawable = null; try { Intent intent = Intent.parseUri(shortcutPojo.intentUri, 0); List<ResolveInfo> packages = packageManager.queryIntentActivities(intent, 0); if (packages.size() > 0) {
Intent intent = Intent.parseUri(intentUri, 0); if (intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
public static void openBaidu(Context context, String poiname, double longitude, double latitude) { try { poiname = (poiname != null) ? poiname : ""; Intent intent = Intent.parseUri("intent://map/direction?" + "destination=latlng:" + latitude + "," + longitude + "|name:" + poiname, 0); context.startActivity(intent); } catch (URISyntaxException e) { Log.e("intent", e.getMessage()); } }
@Override protected Intent parseIntent(XmlResourceParser parser) { String uri = null; try { uri = getAttributeValue(parser, ATTR_URI); return Intent.parseUri(uri, 0); } catch (URISyntaxException e) { Log.w(TAG, "Shortcut has malformed uri: " + uri); return null; // Oh well } } }
public static void startActivity(Context activity,String intentUri) throws URISyntaxException,ActivityNotFoundException { Intent intent = Intent.parseUri(intentUri,Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); if(intent!= null){ activity.startActivity(intent); }else { throw new ActivityNotFoundException(); } }
@Override protected Intent parseIntent(XmlResourceParser parser) { String uri = null; try { uri = getAttributeValue(parser, ATTR_URI); return Intent.parseUri(uri, 0); } catch (URISyntaxException e) { Log.w(TAG, "Shortcut has malformed uri: " + uri); return null; // Oh well } } }
public Intent parseIntent() { String intentDescription = getString(intentIndex); try { return TextUtils.isEmpty(intentDescription) ? null : Intent.parseUri(intentDescription, 0); } catch (URISyntaxException e) { e.printStackTrace(); return null; } }
static public void replyAddressRequest(Activity activity, CoinURI uri, WalletAccount pocket) throws CoinURIParseException { try { String uriString = uri.getAddressRequestUriResponse(pocket.getReceiveAddress()).toString(); Intent intent = Intent.parseUri(uriString, 0); activity.startActivity(intent); } catch (Exception e) { // Should not happen ACRA.getErrorReporter().handleSilentException(e); Toast.makeText(activity, R.string.error_generic, Toast.LENGTH_LONG).show(); } }
/** * Verifies if the intent should be restored. */ private void verifyIntent(String intentStr) throws Exception { Intent intent = Intent.parseUri(intentStr, 0); if (intent.getComponent() != null) { verifyPackage(intent.getComponent().getPackageName()); } else if (intent.getPackage() != null) { // Only verify package if the component was null. verifyPackage(intent.getPackage()); } }
private Decoder(String encoded, Context context) throws JSONException, URISyntaxException { super(encoded); launcherIntent = Intent.parseUri(getString(LAUNCH_INTENT_KEY), 0); user = has(USER_HANDLE_KEY) ? UserManagerCompat.getInstance(context) .getUserForSerialNumber(getLong(USER_HANDLE_KEY)) : Process.myUserHandle(); if (user == null) { throw new JSONException("Invalid user"); } } }
/** * Verifies if the intent should be restored. */ private void verifyIntent(String intentStr) throws Exception { Intent intent = Intent.parseUri(intentStr, 0); if (intent.getComponent() != null) { verifyPackage(intent.getComponent().getPackageName()); } else if (intent.getPackage() != null) { // Only verify package if the component was null. verifyPackage(intent.getPackage()); } }
/** * Verifies if the intent should be restored. */ private void verifyIntent(String intentStr) throws Exception { Intent intent = Intent.parseUri(intentStr, 0); if (intent.getComponent() != null) { verifyPackage(intent.getComponent().getPackageName()); } else if (intent.getPackage() != null) { // Only verify package if the component was null. verifyPackage(intent.getPackage()); } }
/** * Verifies if the intent should be restored. */ private void verifyIntent(String intentStr) throws Exception { Intent intent = Intent.parseUri(intentStr, 0); if (intent.getComponent() != null) { verifyPackage(intent.getComponent().getPackageName()); } else if (intent.getPackage() != null) { // Only verify package if the component was null. verifyPackage(intent.getPackage()); } }