android查询已安装运用所需要的权限

代码如下:

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();
		}
    }
}


android查询已安装运用所需要的权限,布布扣,bubuko.com

android查询已安装运用所需要的权限

上一篇:bsh for android : Inet 地址 Test


下一篇:Android—startActivityForResult的用法