TaskStackBuilder#startActivities() NullPointerException

前端 未结 1 416
无人及你
无人及你 2021-02-06 01:50

I have a crash that keeps occurring on 4.4.2 and 4.4.3 devices (although I\'m not sure this is an API issue), where in some ParsePushBroadcastReceiver the following

1条回答
  •  野的像风
    2021-02-06 02:25

    I wasn't able to solve this problem as I have a suspicion that this might be a bug specific to 4.4.* devices. As an alternative, I replaced my use of the TaskStackBuilder with creating my activities via PendingIntent.getActivities. In my case, this provided equivalent functionality and it was a straightforward replacement. Perhaps you might find it useful as well.

    final Intent parentIntent = new Intent(context, ParentActivity.class);
    parentIntent.putExtra(ParentActivity.EXTRA, extraValue);
    
    final Intent childIntent = new Intent(context, ChildActivity.class);
    childIntent.putExtra(ChildActivity.EXTRA, extraChildValue);
    childIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    
    final Intent[] intents = new Intent [] {parentIntent, childIntent};
    PendingIntent pendingIntent = PendingIntent.getActivities(context, INTENT_REQUEST_CODE, intents, PendingIntent.FLAG_ONE_SHOT);
    
    pendingIntent.send();
    

    0 讨论(0)
提交回复
热议问题