How to go back from calling intent

前端 未结 3 1570
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 02:27

I call camera to take a picture. But I cannot go back to my own original activity after taking the picture. What\'s the problem? Thank you.

    public void a         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 02:30

    Answer

    Use appContext.getExternalCacheDir() and don't forget to mention permissons.

        @Override
            protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                  if (requestCode == TAKE_PICTURE) 
                  {
                          if(resultCode==Activity.RESULT_OK)
                      { //if (data != null)
                        //{   
                        Toast.makeText(this, "Successfully Registered!", Toast.LENGTH_LONG);
                        ImageView Registerimage= (ImageView)findViewById(R.id.RegisterPicture);
                        Registerimage.setImageURI(registeryFileUri);
                        //}
                           }
                          else
                             Toast.makeText(this, "Not Registered!", Toast.LENGTH_LONG);
                 }  
    **"android.permission.CAMERA"**     
    
    Check whether the above permission is specified in your manifest or not
    
    Note: It's better to use getExternalCacheDir() than getFilesDir() if you still dont get the 
          image then use that. Dont forgot to specify the permission "android.permission.WRITE_EXTERNAL_STORAGE" if you use the getExternalCacheDir().
    

提交回复
热议问题