When I create a new Intent in an Activity:
Intent myIntent = new Intent(this, TargetActivity.class);
// apply hacks explained in above stackoverflow answers
System.out.println(myIntent.getExtras())
(this code lays in a default blank activity)
Intent#getExtras()
is always null
and thus Intent#putExtras(...)
leads to immediate NullPointerException
. Starting the Intent, however, works without any problems.
I've read all similar stackoverflow posts about this topic:
- https://stackoverflow.com/a/6357330
- https://stackoverflow.com/a/14288868
- https://stackoverflow.com/a/16458878
- https://stackoverflow.com/a/16377139
- https://stackoverflow.com/a/13596581
- https://stackoverflow.com/a/24047080
- https://stackoverflow.com/a/3128271
I've tried them all, but none of them seems to have any effect.
Could anyone please provide a solution to simply start an Intent with non-null extras which always works?
Alternatively, is there any other way to provide extra information to an Intent which is clean and not leaky?