public class DemoActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
Class clazz =getClass().getClassLoader().loadClass("android.widget.AppSecurityPermissions");
Constructor constructor = clazz.getConstructor(new Class[]{Context.class,String.class});
Object object = constructor.newInstance(new Object[]{this,"cn.itcast.mobilesafe"});
Method method = clazz.getDeclaredMethod("getPermissionsView", new Class[]{});
View view = (View) method.invoke(object, new Object[]{});
setContentView(view);
} catch (Exception e) {
e.printStackTrace();
}
}
}
android典型代码系列(十)------获取一个应用程序的权限信息(反射)
最新推荐文章于 2023-11-17 14:15:47 发布