How to start an activity from a dialog in Android
I created a custom dialog and I'd like to start a new activity when OK is clicked. How can I get the context to set it as first argument of my Intent constructor? I can create the intent using getContext() , but I can't call startActivity . Shall I pass the activity calling the dialog to the dialog's constructor? Is it the usual way to start an activity by clicking a dialog? public class CustomDialog extends Dialog implements OnClickListener { Button okButton, cancelButton; public CustomDialog(Context context) { super(context); setContentView(R.layout.custom_dialog); okButton = (Button)