Android: How To Start An Activity From An Alert Dialog
I need to start an activity when the user chooses an item in an alert dialog. How do I get the context to pass to the intent constructor in the following code... builder.setItems(i
Solution 1:
You can retrieve the context you have passed to AlertDialog.Builder
with getBaseContext()
.
See the doc here.
So this should work:
Intent i = newIntent(getBaseContext(), <new activity>.class);
startActivity(i);
Post a Comment for "Android: How To Start An Activity From An Alert Dialog"