How to handle an intent which does not have data at first call of an activity?
You can do a check for the resultCode
as below.
http://developer.android.com/guide/topics/fundamentals/activities.html#StartingAnActivityForResult
Also, can you identify where exactly you get the exception? (post some code maybe)
EDIT:
Ok, I still donT know where you are calling your login()
method but you can do this check to avoid null exceptions in the line you mentioned:
if( getIntent().getExtras() != null)
{
//do here
}
You can try:
if(intent.getExtras() == null) {
//Do first time stuff here
} else {
//Do stuff with intent data here
}
If you are passing back different intent values every time, you can check if your Bundle object (returned with intent.getExtras()) has certain fields set using this:
Bundle extras = intent.getExtras()
if(extras.containsKey("keytocheck")) {
//Do stuff because extra has been added
}