Gus*_*h88 4 android android-intent google-authenticator
有没有办法通过 Intent 打开 Google Authenticator。如果是,是否可以使用已填充的密钥来打开它,以使其对用户实用?
我有一个更通用的代码,因此,您只需将包名称作为参数发送给方法openApp(Context context, String packageName)
public static void openApp(Context context, String packageName) {
PackageManager manager = context.getPackageManager();
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)));
} catch (android.content.ActivityNotFoundException anfe) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)));
}
return;
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
这样,即使设备没有您尝试启动的应用程序,用户也会被您的应用程序吸引到 Play 商店,并可能下载它。
因此,只需调用openApp(context, "com.google.android.apps.authenticator2");打开 Google Authenticator 应用程序即可。
编辑
您可以使用已设置的所有值来调用 Google Authenticator,如下所示:
String uri = "otpauth://totp/whatever:" + email + "?secret=" + yourKey + "&issuer=whatever"
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3402 次 |
| 最近记录: |