Public void onActivityResult(int requestCode, int resultCode, Intent data)


#1

hi all

why the " public void onActivityResult(int requestCode, int resultCode, Intent data) "
not working ?


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import java.util.Date;
import java.text.SimpleDateFormat;
import android.os.Looper; 
import android.widget.Toast;
import android.app.Activity; 
 
 
private static final int IMAGE_CAPTURE = 102;

 
public void setup(){
  
  final Activity  act = this.getActivity();  
  orientation(LANDSCAPE);  
  Intent intent= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);   
  act.startActivityForResult(intent, IMAGE_CAPTURE);  
}


public void draw(){
 
}


@Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
  
  println("hhhhhhhhhhhhh");
  super.onActivityResult(requestCode, resultCode, data);
  
 final Activity  act = this.getActivity();   
 
      
  if (requestCode == IMAGE_CAPTURE) {
    if (resultCode == Activity.RESULT_OK) {
      PImage jj = (PImage)data.getExtras().get("data");   //(MediaStore.EXTRA_OUTPUT, imageUri);
      
       Toast.makeText(act.getApplicationContext(), "Image saved to:\n" +
                 data.getData(), Toast.LENGTH_LONG).show();
    } else if (resultCode == Activity.RESULT_CANCELED) {
        Toast.makeText(act.getApplicationContext(), "Image cancelled.", 
                     Toast.LENGTH_LONG).show();
    } else {
       Toast.makeText(act.getApplicationContext(), "Failed to take Image", 
                     Toast.LENGTH_LONG).show();
        }
    }
}

#2

Is this related to this current issue in GH? https://github.com/processing/processing-android/issues/452

Kf


#3

Also check https://forum.processing.org/two/search?Search=MediaStore.ACTION_IMAGE_CAPTURE

Related to your current code, can you describe what happens? Do you get any errors?

Kf


#4

no , there is no error …

its seems that the function “public void onActivityResult” not valid or startActivityForResult not valid

thanx