KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I wanted to get the list of all installed shortcuts in the homescreen launcher programmatically. I have found lots of snippets online but none of them provides the right output for this snippet: Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); ArrayList<Intent> intentList = new ArrayList<Intent>(); Intent intent=null; String launchers=""; final PackageManager packageManager=getPackageManager(); for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(shortcutsIntent, 0)) { launchers=launchers+"\n"+resolveInfo.activityInfo.packageName; intent=packageManager .getLaunchIntentForPackage(resolveInfo.activityInfo.packageName); intentList.add(intent); } this only provides the preset shortcuts like contacts, browsers,etc. not exactly what is found in the homescreen. while this snippet: PackageManager pm = getPackageManager(); Intent i = new Intent("android.intent.action.MAIN"); i.addCategory("android.intent.category.HOME"); List<ResolveInfo> lst = pm.queryIntentActivities(i, 0); if (lst != null) { for (ResolveInfo resolveInfo : lst) { } } } only provides the default launcher which is com.android.launcher.
Tags (comma-separated)
Save Edits
Cancel