TaskStackBuilder#startActivities() NullPointerException

放肆的年华 提交于 2019-12-03 02:59:29

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!