Passing Extras From Activity To Intent Throws Nullpointerexception
This is a problem that forked off a different issue. I'm passing two strings from my main activity to a child service, which is fine, but when the main activity dies, the service t
Solution 1:
As per the documentation:
intent - ... This may be null if the service is being restarted
Therefore check for null
intent:
publicintonStartCommand(Intent intent, int flags, int startId) {
intcmd=super.onStartCommand(intent, flags, startId);
if (intent == null) return cmd;
finalStringauthor= intent.getStringExtra("author");
finalStringquote= intent.getStringExtra("quote");
...
}
Post a Comment for "Passing Extras From Activity To Intent Throws Nullpointerexception"