summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/LauncherActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/app/LauncherActivity.java')
-rw-r--r--core/java/android/app/LauncherActivity.java34
1 files changed, 25 insertions, 9 deletions
diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java
index d788c43..a83f4e8 100644
--- a/core/java/android/app/LauncherActivity.java
+++ b/core/java/android/app/LauncherActivity.java
@@ -18,6 +18,7 @@ package android.app;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -70,13 +71,15 @@ public abstract class LauncherActivity extends ListActivity {
ListItem(PackageManager pm, ResolveInfo resolveInfo, IconResizer resizer) {
this.resolveInfo = resolveInfo;
label = resolveInfo.loadLabel(pm);
- if (label == null && resolveInfo.activityInfo != null) {
+ ComponentInfo ci = resolveInfo.activityInfo;
+ if (ci == null) ci = resolveInfo.serviceInfo;
+ if (label == null && ci != null) {
label = resolveInfo.activityInfo.name;
}
icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm));
- packageName = resolveInfo.activityInfo.applicationInfo.packageName;
- className = resolveInfo.activityInfo.name;
+ packageName = ci.applicationInfo.packageName;
+ className = ci.name;
}
public ListItem() {
@@ -325,8 +328,7 @@ public abstract class LauncherActivity extends ListActivity {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
- setContentView(com.android.internal.R.layout.activity_list);
-
+ onSetContentView();
mIntent = new Intent(getTargetIntent());
mIntent.setComponent(null);
@@ -338,10 +340,17 @@ public abstract class LauncherActivity extends ListActivity {
setProgressBarIndeterminateVisibility(false);
}
+ /**
+ * Override to call setContentView() with your own content view to
+ * customize the list layout.
+ */
+ protected void onSetContentView() {
+ setContentView(com.android.internal.R.layout.activity_list);
+ }
+
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
- Intent intent = ((ActivityAdapter)mAdapter).intentForPosition(position);
-
+ Intent intent = intentForPosition(position);
startActivity(intent);
}
@@ -374,12 +383,19 @@ public abstract class LauncherActivity extends ListActivity {
}
/**
+ * Perform query on package manager for list items. The default
+ * implementation queries for activities.
+ */
+ protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) {
+ return mPackageManager.queryIntentActivities(queryIntent, /* no flags */ 0);
+ }
+
+ /**
* Perform the query to determine which results to show and return a list of them.
*/
public List<ListItem> makeListItems() {
// Load all matching activities and sort correctly
- List<ResolveInfo> list = mPackageManager.queryIntentActivities(mIntent,
- /* no flags */ 0);
+ List<ResolveInfo> list = onQueryPackageManager(mIntent);
Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager));
IconResizer resizer = new IconResizer();