we have a scenario where our app ideally should run in the background,
together with a primary app in the front. Here's how we fill the preference
selector
//fill the app list - ignore system apps
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager pm = this.getPackageManager();
final List<ResolveInfo> pkgAppsList =
pm.queryIntentActivities(mainIntent, 0);
// Sort the list
Collections.sort(pkgAppsList, new
ResolveInfo.DisplayNameComparator(pm));
final ArrayList<String> appEntries = new ArrayList<String>();
final ArrayList<String> appEntryValues = new ArrayList<String>();
appEntries.add("nothing");
appEntryValues.add("none,none");
for (ResolveInfo info : pkgAppsList) {
//if (!isSystemPackage(info)) {
appEntries.add(info.activityInfo.loadLabel(pm).toString());
appEntryValues.add(info.activityInfo.packageName+","+info.activityInfo.name);
//}
}
ListPreference appList = (ListPreference)
findPreference("launch_application");
appList.setEntries(appEntries.toArray(new
CharSequence[appEntries.size()]));
appList.setEntryValues(appEntryValues.toArray(new
CharSequence[appEntryValues.size()]));
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en