2012-10-05 14 views
13

Volevo ottenere l'elenco di tutte le scorciatoie installate nel launcher di homescreen a livello di programmazione. Ho trovato un sacco di frammenti online, ma nessuno di loro fornisce l'uscita destraCome ottenere l'elenco di tutte le scorciatoie installate trovate nella schermata iniziale Launcher in Android

per questo frammento:

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);  
} 

questo fornisce solo le scorciatoie preimpostate come contatti, browser, ecc. non esattamente ciò che si trova nella schermata iniziale.

mentre questo frammento:

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) { 
      } 
     } 
    } 

fornisce solo il launcher di default che è com.android.launcher.

+0

Hey hai qualche soluzione di esso? Sono anche bloccato in un problema simile? Potresti per favore aiutarmi .. – Rahil2952

+0

No, non ho, ho informato il mio cliente che è impossibile ottenere quelle informazioni e capiscono. –

+0

k per la tua risposta .. – Rahil2952

risposta

1

La mia risposta potrebbe essere in ritardo, ma potrebbe essere utile per gli altri.

controllare il mio codice:

if (Build.VERSION.SDK_INT <8) 
{ 
url = "content://com.android.launcher.settings/favorites?Notify=true"; 
} 
else 
{ 
url = "content://com.android.launcher2.settings/favorites?Notify=true"; 
} 

ContentResolver resolver = getContentResolver(); 
Cursor cursor = resolver.query (Uri.parse(url), null, null, null, null); 
Problemi correlati