Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IllegalArgumentException in ActivityManagerProxy

Issue: ActivityA starts ActivityB with shared element transitions intermittently crashes Not consistently reproducible Api levels: 23, 24 and 25

Code to launch activity:

Intent intent = new Intent(this, ActivityB.class);
Pair<View, String> logoTransition = Pair.create(logo, getString(R.string.transition_logo));
Pair<View, String> logoTextTransition = Pair.create(logoText, getString(R.string.transition_logo_text));
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, logoTransition, logoTextTransition);
ActivityCompat.startActivity(this, intent, options.toBundle());

Stacktrace (API 23):

Exception java.lang.IllegalArgumentException:
android.os.Parcel.readException (Parcel.java:1606)
android.os.Parcel.readException (Parcel.java:1555)
android.app.ActivityManagerProxy.isTopOfTask (ActivityManagerProxy.java:4787)
android.app.Activity.isTopOfTask (Activity.java:5753)
android.app.Activity.cancelInputsAndStartExitTransition (Activity.java:4075)
android.app.Activity.startActivityForResult (Activity.java:4052)
android.app.Activity.startActivity (Activity.java:4312)
android.support.v4.content.ContextCompat.startActivity (ContextCompat.java)
__null__.getDrawable (ContextCompat.java)
__null__.isDeviceProtectedStorage (ContextCompat.java)
com.my.app.activity.ActivityA.startMainActivity (ActivityA.java)

Does anyone know what causes this behaviour? Any proposed fix for this?

like image 701
Gabor Peto Avatar asked Feb 18 '17 12:02

Gabor Peto


2 Answers

I suppose, you should not use methods from support library for that versions. Sure, I can't figure out, from your existing issue due of random stacktrace.

Since Tranlsation Scene introduced form 4.4. You can include api deprecation. Moreover, it's recommended, otherwise, why we need both types?

 if (Build.VERSION.SDK_INT >= 21) {
       ActivityOptions options = ActivityOptions
      .makeSceneTransitionAnimation(this, logoTransition, logoTextTransition);
       startActivity(this, intent, options.toBundle());
    } 
  else {
       ActivityOptionsCompat options = ActivityOptionsCompat
      .makeSceneTransitionAnimation(this, logoTransition, logoTextTransition);
       ActivityCompat.startActivity(this, intent, options.toBundle());
    }
like image 129
GensaGames Avatar answered Oct 17 '22 01:10

GensaGames


in my case this happen because i subscribe on click action two times, so startActivity was called twice in a row.

hope this can be helpful for some one :)

like image 32
Andriy Antonov Avatar answered Oct 16 '22 23:10

Andriy Antonov