android 获取已安装程序列表
public void btn1Click(View v){
String str = null;
PackageManager manager = this.getPackageManager();
List<PackageInfo> pkgList = manager.getInstalledPackages(0);
for (int i = 0; i < pkgList.size(); i++) {
PackageInfo pI = pkgList.get(i);
str = str + "\n" + pI.packageName;
}
TextView tv1 = (TextView)findViewById(R.id.textView1);
tv1.setMovementMethod(ScrollingMovementMethod.getInstance());
tv1.setText(str);
}
String str = null;
PackageManager manager = this.getPackageManager();
List<PackageInfo> pkgList = manager.getInstalledPackages(0);
for (int i = 0; i < pkgList.size(); i++) {
PackageInfo pI = pkgList.get(i);
str = str + "\n" + pI.packageName;
}
TextView tv1 = (TextView)findViewById(R.id.textView1);
tv1.setMovementMethod(ScrollingMovementMethod.getInstance());
tv1.setText(str);
}