当前位置: 首页>>代码示例>>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;未经允许,请勿转载。