I am launching activity from the service based on some value got from the server and the activity will be displayed for the some time and after getting close instruction fro
Write a broadcast receiver in your CustomDialogActivity like following.
private final BroadcastReceiver abcd = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
finish();
}
};
Then register it in the same file like the following:
onCreate(){
registerReceiver(abcd, new IntentFilter("xyz"));
}
Unregister it in onDestroy.
onDestroy(){
//unRegister
}
Now,Whenever you want to close that Activity just call like the following.
sendBroadcast(new Intent("xyz"));
Hope this help.