mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
implement PackageManager.getLaunchIntentForPackage()
fixes a crash after importing a NewPipe backup
This commit is contained in:
parent
99c1e1ee94
commit
62c964e8bd
2 changed files with 15 additions and 0 deletions
|
@ -368,4 +368,9 @@ public class Intent implements Parcelable {
|
|||
public void removeExtra(String name) {
|
||||
extras.remove(name);
|
||||
}
|
||||
|
||||
public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
|
||||
extras.putParcelableArrayList(name, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1427,6 +1427,16 @@ public class PackageManager {
|
|||
* not contain such an activity.
|
||||
*/
|
||||
public Intent getLaunchIntentForPackage(String packageName) {
|
||||
if (!Context.this_application.getPackageName().equals(packageName))
|
||||
return null;
|
||||
for (PackageParser.Activity activity: Context.pkg.activities) {
|
||||
for (PackageParser.IntentInfo intent: activity.intents) {
|
||||
Slog.i(TAG, intent.toString());
|
||||
if (intent.hasCategory("android.intent.category.LAUNCHER")) {
|
||||
return new Intent("android.intent.action.MAIN", null).setComponent(new ComponentName(packageName, activity.className));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue