我有一个列表活动,显示设备中所有正在运行的应用程序。它为所有应用程序显示默认图标。但是我需要在列表中获取每个应用程序的实际应用程序图标。
public class ApplicationList extends ListActivity {
DataHelper dh;
ImageView vi;
private Drawable icon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.applist);
dh = new DataHelper(getApplicationContext());
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
Log.d("Test1", "INSERTING APP LIST TO SERVER DB");
List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
ArrayList<String> applist = new ArrayList<String>();
for(ResolveInfo rInfo: list){
applist.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString() );
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.installedapp, R.id.textView1, applist);
setListAdapter(adapter);
}
如何获取其他应用程序的图标(Android) 我尝试了这个链接,但没有解决问题。所以有人可以帮助我吗?谢谢!