Android 获取手机所有应用包名以及权限
2012-07-19 14:20:05 来源:WEB开发网 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
.append("权限包括:"
+ p.name
+ "\n");
}
}
stringBuilder.append("\n");
}
mTextView.setText(stringBuilder
.toString());
}
}
- ››手机丢失防止支付宝资金被盗办法
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
赞助商链接