According to new behavior documented here https://developer.android.com/about/versions/pie/android-9.0-changes-all#fant-required starting activities from non-activity context requires FLAG_ACTIVITY_NEW_TASK
flag, perhaps...
So I have created sandbox app that can launch activity of another apps by package name and activity name. The core function used to launching, looks like this:
fun Context.startActivity(packageName: String, activityName: String) {
applicationContext.startActivity(Intent(Intent.ACTION_MAIN).apply {
component = ComponentName(packageName, activityName)
})
}
What is odd, by calling this function I can succesfully start any exported activity without passing FLAG_ACTIVITY_NEW_TASK
.
It is quite different from what google saying about that. Or maybe I wrongly understand this new behavior requirements?
Off course I tested this on API 28 but also on lower API's.
Can someone explain in which cases this new behavior can breaks any feature that works on older APIs?
As per this change it seems to be a restriction when FLAG_ACTIVITY_NEW_TASK is not set while launching an activity from a non-activity context.
StartActivity method in Activity.java is overriden and avoid this restriction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With