Skip to content

Commit 214a0ef

Browse files
author
tiann
committed
FIX: when the app has multiple MAIN entry, the launch intent will select the first always, which maybe an disabled component. We should always select the enabled one.
1 parent c6e9e05 commit 214a0ef

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

VirtualApp/lib/src/main/java/com/lody/virtual/client/core/VirtualCore.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,24 @@ public Intent getLaunchIntent(String packageName, int userId) {
443443
if (ris == null || ris.size() <= 0) {
444444
return null;
445445
}
446+
447+
ActivityInfo activityInfo = null;
448+
for (ResolveInfo resolveInfo : ris) {
449+
if (resolveInfo.activityInfo.enabled) {
450+
// select the first enabled component
451+
activityInfo = resolveInfo.activityInfo;
452+
break;
453+
}
454+
}
455+
456+
if (activityInfo == null) {
457+
activityInfo = ris.get(0).activityInfo;
458+
}
459+
446460
Intent intent = new Intent(intentToResolve);
447461
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
448-
intent.setClassName(ris.get(0).activityInfo.packageName,
449-
ris.get(0).activityInfo.name);
462+
intent.setClassName(activityInfo.packageName,
463+
activityInfo.name);
450464
return intent;
451465
}
452466

0 commit comments

Comments
 (0)