我想知道是否有可能动态获得Android权限而不使用AndroidManifest只需要一些代码,因为我在Android上运行了一些OSGi包,没有Android权限,因此功能受到限制.
感谢您的回答,是的,它使用户体验变得复杂,如果提供了该机制,对用户也是危险的
现在我正在开发一个应用程序.通过我的应用程序用户可以阅读pdf文件,如果没有pdf阅读器,那么我的应用程序将自动从网站安装它.这是我用来阅读pdf文件的代码.
File file = new File("/sdcard/sample.pdf");
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0 && file.isFile()) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
我的怀疑是: