Android App Reacts Properly To To Phone's Back Button But Crashes With Nulpointerexception When Clicked On Menu's Back Button
i have an activity (say A2) which gets an id from its parent activity (say A1) and after fetching results from database prepares a list. on clicking a list item it passes the anoth
Solution 1:
okay...so it worked out. i had to set the launchMode=singleTop property inside the manifest file for activity A2(allclasses) like below so that system keeps instance created for A2 activity alive in backstack
android:launchMode="singleTop"
and then just call navUtils.navigateUpFromSameTask(this) method from activity A3 to call the same instance from the backstack instead of creating a new instance.
@OverridepublicbooleanonOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
returntrue;
}
returnsuper.onOptionsItemSelected(menuItem);
}
hmm...simple solution haa...:D ... Thanks guys for your help... !!
Solution 2:
Try
getParentActivityIntent()
instead of getParent()
Post a Comment for "Android App Reacts Properly To To Phone's Back Button But Crashes With Nulpointerexception When Clicked On Menu's Back Button"