Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92
之前在Android4.4上也做过此功能,Android6.0有变化,请同事帮忙添加了~
实现:
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 4ba678c..7856c56 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -865,6 +865,25 @@ public class ResolverActivity extends Activity {
}
}
if (count > 0) {
+ if (mAdapter.mOrigResolveList != null) {
+ int size = mAdapter.mOrigResolveList.size();
+ for(int j = 0; j < size; j++) {
+ final ResolveInfo r = mAdapter.mOrigResolveList.get(j).getResolveInfoAt(0);;
+ Log.e(TAG, "Package Name:"+r.activityInfo.packageName+" Class Name:"+r.activityInfo.name);
+ if (r.activityInfo.packageName.equals("com.app.test")){
+ Log.e(TAG, "Start app test as launcher!");
+ final TargetInfo target = mAdapter.targetInfoForPosition(j, false);
+ if (shouldAutoLaunchSingleChoice(target)) {
+ safelyStartActivity(target);
+ mPackageMonitor.unregister();
+ mRegistered = false;
+ finish();
+ return true;
+ }
+ }
+ }
+ }
setContentView(layoutId);
mAdapterView = (AbsListView) findViewById(R.id.resolver_list);
onPrepareAdapterView(mAdapterView, mAdapter, alwaysUseOption);