Reputation: 217
I am writing an application which is having an activity and I am launching a pop up ( pop up I have implemented in another class which is not an activity). In my main activity I have code to display the popup when there is an event. I am successfully able to do that. But I need to cancel the popup when I get another event. ( I will get this event only in the main activity). How can I finish the popup from the main activity when I receive the event?
Upvotes: 1
Views: 1133
Reputation: 1371
final AlertDialog.Builder aBuilder;
//constructor(Context c){//mContext = c;}
public void showMessage(final String title, final String s) {
aBuilder = new AlertDialog.Builder(mContext);
aBuilder.setTitle(title);
aBuilder.setIcon(R.drawable.ic_launcher);
// aBuilder.setIcon(R.drawable.icon);
aBuilder.setMessage(s);
}
public void dismissMessage() {
aBuilder.dismiss();
}
Upvotes: 0
Reputation: 1371
create a public method in the class where you have created the popUP(dialog) and write inside it as
public void dismissDialog(){
dialog.dismiss();
}
then whenever you want to remove the dialog call this method...
Upvotes: 2