I dont' understand why we use method getIntent()
.
Because, when we need that method, We can use method onActivityResult()
.
But by using the method getIntent()
, it could cause NullPointerException
.
http://developer.android.com/reference/android/app/Activity.html#getIntent()
Return the intent that started this activity.
If you start an Activity with some data, for example by doing
Intent intent = new Intent(context, SomeActivity.class);
intent.putExtra("someKey", someData);
you can retrieve this data using getIntent in the new activity:
Intent intent = getIntent();
intent.getExtra("someKey") ...
So, it's not for handling returning data from an Activity, like onActivityResult, but it's for passing data to a new Activity.