search

Home  >  Q&A  >  body text

android中如何用代码结束拍照的activity?

假设我在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?或者有没有其他的思路?

高洛峰高洛峰2773 days ago327

reply all(3)I'll reply

  • 阿神

    阿神2017-04-17 17:59:48

    Can be updated when you return

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:59:48

    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.

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 17:59:48

    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.

    reply
    0
  • Cancelreply