Created
October 5, 2017 14:19
-
-
Save dario61081/16adcb3bc04f16e209d2963adac660a3 to your computer and use it in GitHub Desktop.
get information about apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NonNull | |
@Override | |
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { | |
View view = convertView; | |
if (view == null){ | |
view = View.inflate(getContext(), R.layout.layout_app_item, null); | |
} | |
ResolveInfo info = getItem(position); | |
Drawable icon = getContext().getResources().getDrawable(android.R.drawable.sym_def_app_icon); | |
String lbl = ""; | |
try { | |
PackageManager pm = getContext().getPackageManager(); | |
ApplicationInfo appinfo = pm.getApplicationInfo(info.activityInfo.packageName, PackageManager.GET_META_DATA); | |
icon = pm.getApplicationIcon(appinfo); | |
lbl = pm.getApplicationLabel(appinfo).toString(); | |
} catch (Exception e){ | |
Log.w(TAG, "getView: " + e.getMessage() ); | |
} | |
ImageView imageView = view.findViewById(R.id.img_app_item_icon); | |
imageView.setImageDrawable(icon); | |
TextView lbl_aplicacion = view.findViewById(R.id.lbl_app_item_name); | |
lbl_aplicacion.setText(lbl); | |
return view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment