23

Hi I am using following code but sometimes app is crashing with error:

java.lang.IllegalArgumentException in startActivity(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();

Here is the crash logs

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 at 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)

Arpit
  • 1,259
  • 11
  • 21
Rahul Devanavar
  • 3,917
  • 4
  • 32
  • 61
  • Can you provide a stacktrace? – davidgiga1993 Jun 24 '15 at 12:38
  • 0java.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(ActivityManagerNative.java:4465) 4 at android.app.Activity.isTopOfTask(Activity.java:5361) 5 at android.app.Activity.startActivityForResult(Activity.java:3770) 6 at android.app.Activity.startActivity(Activity.java:4003) 7 at com.tapcibo.tapcibo.uifragment.LaunchActivity.a(SourceFile:105) – Rahul Devanavar Jun 24 '15 at 12:40
  • @RahulDevanavar - could you edit that into your question? – andrewsi Jun 24 '15 at 12:43

3 Answers3

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.

Marcel
  • 2,094
  • 3
  • 23
  • 37
  • 3
    Hello have you found the solution? I am facing the same problem and having trouble with it. The thing is, I am using Theme.AppCompat.Light and not transparent themes, I am also using ActivityCompatOptions.makeSceneTransitionAnimation and it presents the same problem – John Ernest Guadalupe Sep 10 '15 at 15:36
  • 2
    hi! I am also using Theme.AppCompat.Light.DarkActionBar, but have same issue. any solutions? – Andriy Antonov Jul 06 '17 at 07:46
6

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

mieszk3
  • 276
  • 3
  • 9
0

instead of

startActivity(slideactivity, bndlanimation);

use

ActivityCompat.startActivity(this, slideactivity, bndlanimation)
Ihor Bykov
  • 1,843
  • 3
  • 15
  • 22