Android camera intent

前端 未结 6 777
旧巷少年郎
旧巷少年郎 2020-11-22 11:47

I need to push an intent to default camera application to make it take a photo, save it and return an URI. Is there any way to do this?

6条回答
  •  借酒劲吻你
    2020-11-22 12:31

    Try the following I found here

    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    startActivityForResult(intent, 0);
    
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (resultCode == Activity.RESULT_OK && requestCode == 0) {
        String result = data.toURI();
        // ...
      }
    }
    

提交回复
热议问题