关于startActivity的rjava.lang.IllegalArgumentException(intent,bundle animantion)

时间:2015-06-24 12:35:24

标签: android android-intent android-activity

您好我正在使用以下代码,但有时应用程序崩溃并出现错误:

  

startActivity中的java.lang.IllegalArgumentException(slideactivity,bndlanimation);

if (android.os.Build.VERSION.SDK_INT >= 16) {
       Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(), R.anim.slide_in, R.anim.slide_out).toBundle();
       startActivity(slideactivity, bndlanimation);
     } else
       startActivity(slideactivity);
       finish();

以下是崩溃日志

  

java.lang.IllegalArgumentException 1 at   android.os.Parcel.readException(Parcel.java:1553)2 at   android.os.Parcel.readException(Parcel.java:1499)3 at   android.app.ActivityManagerProxy.isTopOfTask(ActivityManager Native.java:4465)   4在android.app.Activity.isTopOfTask(Activity.java:5361)5 at   android.app.Activity.startActivityForResult(Activity.java:37 70)6 at   android.app.Activity.startActivity(Activity.java:4003)7 at   com.tapcibo.tapcibo.uifragment.LaunchActivity.a(的SourceFile:1 05)

3 个答案:

答案 0 :(得分:6)

I found the problem, after digging really deep I saw that there is some problem with the SDK > 21 so lollipop up. In my case this happens when using transparent theme together with some enter and exit transitions.

Two options:

If I remove the ActivityOptions.makeCustomAnimation().toBundle(); and work good again.

If I set my theme to my app normal theme works good too.

I will have to investigate further but I guess there is some configuration on the theme that makes this crash.

答案 1 :(得分:0)

而不是

startActivity(slideactivity, bndlanimation);

使用

ActivityCompat.startActivity(this, slideactivity, bndlanimation)

答案 2 :(得分:0)

Try to use ActivityOptionsCompat instead of ActivityOptions if you are using ActivityCompat.startActivity(). As well use ActivityOptionsCompat.makeSceneTransitionAnimation() to make animation options.