You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement PackageManager.getLaunchIntentForPackage()
fixes a crash after importing a NewPipe backup
This commit is contained in:
@@ -368,4 +368,9 @@ public class Intent implements Parcelable {
|
|||||||
public void removeExtra(String name) {
|
public void removeExtra(String name) {
|
||||||
extras.remove(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.
|
* not contain such an activity.
|
||||||
*/
|
*/
|
||||||
public Intent getLaunchIntentForPackage(String packageName) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user