當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.parseUri方法代碼示例

本文整理匯總了Java中android.content.Intent.parseUri方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.parseUri方法的具體用法?Java Intent.parseUri怎麽用?Java Intent.parseUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.parseUri方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleIntentUrl

import android.content.Intent; //導入方法依賴的package包/類
private static boolean handleIntentUrl(WebView view, String url) {
    if (TextUtils.isEmpty(url) || !url.startsWith("intent://"))

        return false;
    try {
        Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
        ResolveInfo info = PackageUtil.getResolveInfo(view.getContext(), intent);
        if (info != null) {
            if (!(view.getContext() instanceof Activity))
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            view.getContext().startActivity(intent);
            return true;
        }
    } catch (URISyntaxException e) {
        Log.printStackTrace(e);
    }


    return false;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:21,代碼來源:WebModel.java

示例2: getIntentFromUri

import android.content.Intent; //導入方法依賴的package包/類
/**
 * 從uri中解析出Intent
 *
 * @param context 上下文
 * @param uri     uri
 * @param flags   intentFlags
 *
 * @return Intent
 */
public static Intent getIntentFromUri(Context context, String uri, int flags) {
	try {
		Intent intent = Intent.parseUri(uri, flags);
		if (intent == null) {
			return null;
		}
		List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
		if (list == null || list.isEmpty()) {
			return null;
		}
		if (!(context instanceof Activity)) {
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		}
		return intent;
	} catch (Throwable e) {
		DLog.e(e);
	}
	return null;
}
 
開發者ID:youmi,項目名稱:nativead,代碼行數:29,代碼來源:IntentUtils.java

示例3: launchClockAction

import android.content.Intent; //導入方法依賴的package包/類
private static void launchClockAction(String uri) {
    if (mContext == null) return;

    try {
        final Intent intent = Intent.parseUri(uri, 0);
        if (intent != null) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            mContext.startActivity(intent);
            if (mPhoneStatusBar != null) {
                XposedHelpers.callMethod(mPhoneStatusBar, "animateCollapsePanels");
            }
        }
    } catch (ActivityNotFoundException e) {
        log("Error launching assigned app for long-press on clock: " + e.getMessage());
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:19,代碼來源:ModStatusBar.java

示例4: launchCustomApp

import android.content.Intent; //導入方法依賴的package包/類
private static void launchCustomApp(String uri) {
    if (uri == null) {
        try {
            Handler handler = (Handler) XposedHelpers.getObjectField(mPhoneWindowManager, "mHandler");
            handler.post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(mContext, mStrCustomAppNone, Toast.LENGTH_SHORT).show();
                }
            });
        } catch (Throwable t) {
        }
        return;
    }

    try {
        Intent i = Intent.parseUri(uri, 0);
        launchCustomApp(i);
    } catch (URISyntaxException e) {
        log("launchCustomApp: error parsing uri: " + e.getMessage());
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:23,代碼來源:ModHwKeys.java

示例5: parseIntent

import android.content.Intent; //導入方法依賴的package包/類
@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
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:12,代碼來源:DefaultLayoutParser.java

示例6: parseIntent

import android.content.Intent; //導入方法依賴的package包/類
public Intent parseIntent() {
    String intentDescription = getString(intentIndex);
    try {
        return TextUtils.isEmpty(intentDescription) ?
                null : Intent.parseUri(intentDescription, 0);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:11,代碼來源:LoaderCursor.java

示例7: verifyIntent

import android.content.Intent; //導入方法依賴的package包/類
/**
 * 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());
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:13,代碼來源:GridSizeMigrationTask.java

示例8: insertAndCheck

import android.content.Intent; //導入方法依賴的package包/類
@Override
public long insertAndCheck(SQLiteDatabase db, ContentValues values) {
    if (mExistingItems.size() >= mRequiredSize) {
        // No need to add more items.
        return 0;
    }
    Intent intent;
    try {
        intent = Intent.parseUri(values.getAsString(Favorites.INTENT), 0);
    } catch (URISyntaxException e) {
        return 0;
    }
    String pkg = getPackage(intent);
    if (pkg == null || mExisitingApps.contains(pkg)) {
        // The item does not target an app or is already in hotseat.
        return 0;
    }
    mExisitingApps.add(pkg);

    // find next vacant spot.
    long screen = 0;
    while (mExistingItems.get(screen) != null) {
        screen++;
    }
    mExistingItems.put(screen, intent);
    values.put(Favorites.SCREEN, screen);
    mOutOps.add(ContentProviderOperation.newInsert(Favorites.CONTENT_URI).withValues(values).build());
    return 0;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:30,代碼來源:ImportDataTask.java

示例9: from

import android.content.Intent; //導入方法依賴的package包/類
public static BitmapShortcut from(String ident){
    String[] parts = ident.split("\\|");
    if (parts.length < 4) return null;
    try {
        String uri = decodeText(parts[1]);
        Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
        return new BitmapShortcut(parts[2],decodeBitmap(parts[3]), intent, parts[3]);
    } catch (URISyntaxException ignored) {
    }
    return null;
}
 
開發者ID:jathak,項目名稱:sflauncher,代碼行數:12,代碼來源:App.java

示例10: startIntentUrl

import android.content.Intent; //導入方法依賴的package包/類
private static void startIntentUrl(Activity activity, String intentFullUrl) {
    try {
        Intent intent = Intent.parseUri(intentFullUrl, Intent.URI_INTENT_SCHEME);
        activity.startActivity(intent);
    } catch (URISyntaxException | ActivityNotFoundException e) {
        Timber.e(e);
    }
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:9,代碼來源:AlipayDonate.java

示例11: canExternalAppHandleUrl

import android.content.Intent; //導入方法依賴的package包/類
/**
 * @return Whether the |url| could be handled by an external application on the system.
 */
public boolean canExternalAppHandleUrl(String url) {
    if (url.startsWith(SCHEME_WTAI_MC)) return true;
    try {
        Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
        if (intent.getPackage() != null) return true;

        List<ResolveInfo> resolvingInfos = mDelegate.queryIntentActivities(intent);
        if (resolvingInfos != null && resolvingInfos.size() > 0) return true;
    } catch (Exception ex) {
        // Ignore the error.
        Log.w(TAG, "Bad URI %s", url, ex);
    }
    return false;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:ExternalNavigationHandler.java

示例12: redirectAndStartAlipay

import android.content.Intent; //導入方法依賴的package包/類
private void redirectAndStartAlipay(String redirectUrl) {
    LogInfo.log("CRL 支付寶支付 跳轉並打開支付寶錢包 == " + redirectUrl);
    LogInfo.log("CRL 支付寶支付 跳轉並打開支付寶錢包 isPackageAvailable== " + isPackageAvailable(this, "com.eg.android.AlipayGphone"));
    String requestUrl = "";
    if (isPackageAvailable(this, "com.eg.android.AlipayGphone")) {
        try {
            requestUrl = ALIPAY_SCHEME_HEADER + URLEncoder.encode(redirectUrl, "UTF-8");
            LogInfo.log("CRL 支付寶支付 跳轉並打開支付寶錢包 requestUrl== " + requestUrl);
            Intent intent = null;
            try {
                intent = Intent.parseUri(requestUrl, 1);
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
            startActivity(intent);
            return;
        } catch (UnsupportedEncodingException e2) {
            e2.printStackTrace();
            return;
        }
    }
    try {
        requestUrl = ALIPAY_HTTP_HEADER + URLEncoder.encode(ALIPAY_HTTP_SCHEME_KEY + URLEncoder.encode(redirectUrl, "UTF-8"), "UTF-8");
        LogInfo.log("CRL 支付寶支付 跳轉並打開支付寶錢包 requestUrl== " + requestUrl);
    } catch (UnsupportedEncodingException e22) {
        e22.printStackTrace();
    }
    if (!TextUtils.isEmpty(requestUrl)) {
        new LetvWebViewActivityConfig(this).launch(requestUrl, "", true, false);
    }
    finish();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:VipOrderDetailActivity.java

示例13: invalidPackageOrClass

import android.content.Intent; //導入方法依賴的package包/類
@Override
protected long invalidPackageOrClass(XmlResourceParser parser) {
    final String uri = getAttributeValue(parser, ATTR_URI);
    if (TextUtils.isEmpty(uri)) {
        return -1;
    }

    final Intent metaIntent;
    try {
        metaIntent = Intent.parseUri(uri, 0);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return -1;
    }

    ResolveInfo resolved = mPackageManager.resolveActivity(metaIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    final List<ResolveInfo> appList = mPackageManager.queryIntentActivities(
            metaIntent, PackageManager.MATCH_DEFAULT_ONLY);

    // Verify that the result is an app and not just the resolver dialog asking which
    // app to use.
    if (wouldLaunchResolverActivity(resolved, appList)) {
        // If only one of the results is a system app then choose that as the default.
        final ResolveInfo systemApp = getSingleSystemActivity(appList);
        if (systemApp == null) {
            // There is no logical choice for this meta-favorite, so rather than making
            // a bad choice just add nothing.
            return -1;
        }
        resolved = systemApp;
    }
    final ActivityInfo info = resolved.activityInfo;
    final Intent intent = mPackageManager.getLaunchIntentForPackage(info.packageName);
    if (intent == null) {
        return -1;
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

    return addShortcut(info.loadLabel(mPackageManager).toString(), intent,
            Favorites.ITEM_TYPE_APPLICATION);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:44,代碼來源:DefaultLayoutParser.java

示例14: convertShortcutsToLauncherActivities

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
 * launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
 */
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
    db.beginTransaction();
    Cursor c = null;
    SQLiteStatement updateStmt = null;

    try {
        // Only consider the primary user as other users can't have a shortcut.
        long userSerial = getDefaultUserSerial();
        c = db.query(Favorites.TABLE_NAME, new String[] {
                Favorites._ID,
                Favorites.INTENT,
            }, "itemType=" + Favorites.ITEM_TYPE_SHORTCUT + " AND profileId=" + userSerial,
            null, null, null, null);

        updateStmt = db.compileStatement("UPDATE favorites SET itemType="
                + Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?");

        final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
        final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);

        while (c.moveToNext()) {
            String intentDescription = c.getString(intentIndex);
            Intent intent;
            try {
                intent = Intent.parseUri(intentDescription, 0);
            } catch (URISyntaxException e) {
                e.printStackTrace();
                continue;
            }

            if (!Utilities.isLauncherAppTarget(intent)) {
                continue;
            }

            long id = c.getLong(idIndex);
            updateStmt.bindLong(1, id);
            updateStmt.executeUpdateDelete();
        }
        db.setTransactionSuccessful();
    } catch (SQLException ex) {
        ex.printStackTrace();
    } finally {
        db.endTransaction();
        if (c != null) {
            c.close();
        }
        if (updateStmt != null) {
            updateStmt.close();
        }
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:56,代碼來源:LauncherProvider.java

示例15: decode

import android.content.Intent; //導入方法依賴的package包/類
private static PendingInstallShortcutInfo decode(String encoded, Context context) {
    try {
        JSONObject object = (JSONObject) new JSONTokener(encoded).nextValue();
        Intent launcherIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);

        if (object.optBoolean(APP_SHORTCUT_TYPE_KEY)) {
            // The is an internal launcher target shortcut.
            UserHandleCompat user = UserManagerCompat.getInstance(context)
                    .getUserForSerialNumber(object.getLong(USER_HANDLE_KEY));
            if (user == null) {
                return null;
            }

            LauncherActivityInfoCompat info = LauncherAppsCompat.getInstance(context)
                    .resolveActivity(launcherIntent, user);
            return info == null ? null : new PendingInstallShortcutInfo(info, context);
        }

        Intent data = new Intent();
        data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launcherIntent);
        data.putExtra(Intent.EXTRA_SHORTCUT_NAME, object.getString(NAME_KEY));

        String iconBase64 = object.optString(ICON_KEY);
        String iconResourceName = object.optString(ICON_RESOURCE_NAME_KEY);
        String iconResourcePackageName = object.optString(ICON_RESOURCE_PACKAGE_NAME_KEY);
        if (iconBase64 != null && !iconBase64.isEmpty()) {
            byte[] iconArray = Base64.decode(iconBase64, Base64.DEFAULT);
            Bitmap b = BitmapFactory.decodeByteArray(iconArray, 0, iconArray.length);
            data.putExtra(Intent.EXTRA_SHORTCUT_ICON, b);
        } else if (iconResourceName != null && !iconResourceName.isEmpty()) {
            Intent.ShortcutIconResource iconResource =
                new Intent.ShortcutIconResource();
            iconResource.resourceName = iconResourceName;
            iconResource.packageName = iconResourcePackageName;
            data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
        }

        return new PendingInstallShortcutInfo(data, context);
    } catch (JSONException | URISyntaxException e) {
        Log.d(TAG, "Exception reading shortcut to add: " + e);
    }
    return null;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:44,代碼來源:InstallShortcutReceiver.java


注:本文中的android.content.Intent.parseUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。