Android获取进程的权限信息
2016-06-25 17:50
555 查看
手机设置里面就有获取权限信息,所以AppSecurityPermissions类是存在的,只是系统隐藏起来了,咱用反射的技术,从运行时里面把AppSecurityPermissions类获取出来
另外sv_app_detail 是ScrollView
sv_app_detail = (ScrollView) findViewById(R.id.sv_app_detail);
// 获取权限代码 try { Class clazz = getClass().getClassLoader().loadClass( "android.widget.AppSecurityPermissions");// 得到这AppSecurityPermissions对应的字节码 Constructor constructor = clazz.getConstructor(new Class[] { Context.class, String.class });// 找到这字节码的构造方法,这个AppSecurityPermissions里面的构造方法有两个参数,一个是上下文,一个是string类型的包名 Object object = constructor.newInstance(new Object[] { this, packname });//newInstance就是得到实例 Method method = clazz.getDeclaredMethod("getPermissionsView", new Class[] {});//获取里面某一个方法,第一个参数是方法名,第二个是方法所接收的参数,当前这个方法不需要接收参数 View view = (View) method.invoke(object, new Object[] {});//invoke是把这个方法调用起来,第一个参数是激活哪一个对象里的方法,第二个参数是这个方法所接收的参数,当前这个方法不需要接收参数 sv_app_detail.addView(view); } catch (Exception e) { e.printStackTrace(); }
另外sv_app_detail 是ScrollView
sv_app_detail = (ScrollView) findViewById(R.id.sv_app_detail);
相关文章推荐
- Activity中windowSoftInputMode属性
- AsyncTask
- android学习之代码混淆小结
- android 自定义控件(四)自定义进度条
- Android_ListView控件_使用注意事项
- Android连接蓝牙耳机播放音乐
- Android知识整理<一>Activity
- Android JNI 传递对象
- Android中的Shape使用总结
- android 自定义控件(三) 进度条切换
- android.database.sqlite.SQLiteException: table has no column XXX (code 1)问题解决方法
- android之imgView插件的使用
- 通过Android录音进行简单音频分析
- android 源码编译中的错误 解决
- [android] socket在手机上的应用
- Android中WebView加载本地Html,与JavaScript与Android方法相互传值
- 自定义加载等待动画,仿金山词霸
- Android 应用进程启动流程
- Android 观察者与被观察者
- android 显示/隐藏 view