假设我在activityA中打开相机:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
在相机拍摄过程中,收到来自服务器的message,需要在activityA中,执行某些操作,例如addview
但是activityA已经不再forground了,这个时候怎么用code来finish拍照的activity?或者有没有其他的思路?
Can be updated when you return
This kind of thing can only be done after returning from taking photos. You can save the message to another place first, and when you return to the Activity, check it during onResume to see if there is any unprocessed message, and update it if there is any.
I don’t think you need to close the activity that takes pictures. When you receive a message pushed by the server in the background, you can automatically pop up your activityA, that is, put your activityA in the foreground, or you can also pop up one in the notification bar. Notification allows the user to decide to continue taking photos or enter activityA, which can solve your problem.