I have a list activity which display all running applications in the device. it's displaying a default icon for all application . but I need to get actual application Icon for each application in the list.
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);
}
How to get the icon of other applications (Android) I tried this link but I did not get things solved. so can any one help me out. thanks!
try like this
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
Drawable[] icons=new Drawable[packs.size];
for(int i=0;i<packs.size();i++) {
PackageInfo p = packs.get(i);
icons[i]= p.applicationInfo.loadIcon(getPackageManager());
}
try this:
Icon icon = p.applicationInfo.loadIcon(getPackageManager());
imageView.setImageDrawable(icon);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With