Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
718 views
in Technique[技术] by (71.8m points)

android - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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());
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...