我的代码应该检查-如果安装了特定的应用程序:
yes -启动它
no -启动play商店并搜索应用程序
public void checkXposedInstaller() {
String packageName = "de.robv.android.xposed.installer";
//check if app is installed
try {
PackageManager manager = getPackageManager();
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
checkXposedFramework();
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(this, "app not found", Toast.LENGTH_LONG).show(); //*** download and root install apk
// search on browser/market
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (android.content.ActivityNotFoundException e1) {
Toast.makeText(this, "no app found to handle request", Toast.LENGTH_LONG).show();
}
}
}
但它没有做任何这些事情。然而,奇怪的是,当我将包名称与com.google.app
之类的其他名称互换时,它就像是一个护身符!我在这里做错了什么?
PS: try块不执行任何操作,不会发生崩溃,也不会捕获日志
https://stackoverflow.com/questions/50558277
复制相似问题