That you can do, but I think you should not break the normal flow of activity. If you want to finish you activity then you can simply send a broadcast from your activity B to activity A.
Create a broadcast receiver before starting your activity B:
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent intent) {
String action = intent.getAction();
if (action.equals("finish_activity")) {
finish();
// DO WHATEVER YOU WANT.
}
}
};
registerReceiver(broadcastReceiver, new IntentFilter("finish_activity"));
Send broadcast from activity B to activity A when you want to finish activity A from B
Intent intent = new Intent("finish_activity");
sendBroadcast(intent);
I hope it will work for you...