Android 获取手机所有应用包名以及权限
package gongzibai.co.cc;
import java.util.List;
import android.app.Activity;
import android.app.Application;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.os.Bundle;
import android.widget.TextView;
public class Package1Activity extends
Activity {
TextView mTextView;
/** Called when the activity is first created. */
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextView = (TextView) findViewById(R.id.textView1);
PackageManager packageManager = getPackageManager();
List<PackageInfo> list = packageManager
.getInstalledPackages(PackageManager.GET_PERMISSIONS);
StringBuilder stringBuilder = new StringBuilder();
for (PackageInfo packageInfo : list) {
stringBuilder
.append("package name:"
+ packageInfo.packageName
+ "\n");
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
stringBuilder
.append("应用名称:"
+ applicationInfo
.loadLabel(packageManager)
+ "\n");
if (packageInfo.permissions != null) {
for (PermissionInfo p : packageInfo.permissions) {
stringBuilder www.zzzyk.com
.append("权限包括:"
+ p.name
+ "\n");
}
}
stringBuilder.append("\n");
}
mTextView.setText(stringBuilder
.toString());
}
}
作者:gongzibai
补充:移动开发 , Android ,