Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashes on building back stack

Tags:

android

kotlin

I am building in my IntentService a back stack. I am receiving crash reports from Kitkat devices.

My code is very simple and I don't know what could be the reason. I have a stacktrace but it's not getting me anywhere. Anyone experienced something like this?

    override fun onHandleIntent(intent: Intent?) {
        if (intent != null) {
            val articleIntent = intentFor<ArticleActivity>()
            articleIntent.putExtras(intent)
            TaskStackBuilder.create(this).addNextIntent(intentFor<DrawerActivity>()).addNextIntent(articleIntent).startActivities()
        }
    }

Exception from Crashlytics

java.lang.NullPointerException
       at android.os.Parcel.readException(Parcel.java:1471)
       at android.os.Parcel.readException(Parcel.java:1419)
       at android.app.ActivityManagerProxy.startActivities(ActivityManagerNative.java:4473)
       at android.app.Instrumentation.execStartActivitiesAsUser(Instrumentation.java:1496)
       at android.app.ContextImpl.startActivitiesAsUser(ContextImpl.java:1417)
       at android.content.ContextWrapper.startActivitiesAsUser(ContextWrapper.java:356)
       at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:221)
       at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:232)
       at android.app.TaskStackBuilder.startActivities(TaskStackBuilder.java:208)
       at se.omni.gcm.OpenArticleService.onHandleIntent(OpenArticleService.kt:27)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:157)
       at android.os.HandlerThread.run(HandlerThread.java:61)
like image 663
Damian Petla Avatar asked Oct 15 '15 08:10

Damian Petla


1 Answers

I just found similar question on the SO TaskStackBuilder#startActivities() NullPointerException with answer that satisfy me. Since I started a bounty, I cannot close or delete this question.

like image 169
Damian Petla Avatar answered Sep 20 '22 07:09

Damian Petla