android10 / Android-CleanArchitecture-Kotlin

This is a movies sample app in Kotlin, which is part of a serie of blog posts I have written about architecting android application using different approaches.
https://fernandocejas.com/2018/05/07/architecting-android-reloaded/
4.64k stars 920 forks source link

FLAG_ACTIVITY_NEW_TASK Android M Error #25

Closed Martindgadr closed 6 years ago

Martindgadr commented 6 years ago

Hi there,

I found an issue running the example into android M version in Motorola Moto G (3 generation), the issue was related with Youtube Intent when i'm trying to run the movie on the project. The app crash immediately.
The obvious solution I toke was check the version and add Intent Flag for this one. Navigator.kt --> createYoutubeIntent function.

if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.M) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK

I don't know if this is the best solution... but works, the best part of this is running same project with other phone with Android O works great, so there is a difference in stack related with application context injected.

Zhuinden commented 6 years ago

Start intent should be built from Activity context.

android10 commented 6 years ago

Thanks @Martindgadr ...but my question with this solution is:

If you go back to the app and you play another video, another instance of the youtube activity is created right?

I know there are tons of bugs related to activities stacks, and especially in older android versions.

After some research, Stackoverflow confirmed it:

https://stackoverflow.com/questions/9772927/flag-activity-new-task-clarification-needed (a bit old but valid).

Also, could you post the logcat so we can see in detail what is going on?

android10 commented 6 years ago

Oki, closing..since https://github.com/android10/Android-CleanArchitecture-Kotlin/pull/28 has been merged!

@Martindgadr thanks for the contribution.