代码如下:
import java.lang.reflect.Constructor; import java.lang.reflect.Method; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.View; public class DemoActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); //AppSecurityPermissions try { Class clazz = getClass().getClassLoader().loadClass("android.widget.AppSecurityPermissions"); Constructor constructor = clazz.getConstructor(new Class[]{Context.class,String.class}); //"com.example.mobilesafe"是所要查询的运用的包名 Object object = constructor.newInstance(new Object[]{this,"com.example.mobilesafe"}); Method method = clazz.getDeclaredMethod("getPermissionsView", new Class[]{}); View view = (View) method.invoke(object, new Object[]{}); setContentView(view); } catch (Exception e) { e.printStackTrace(); } } }