嗨,我在将图像路径发送到另一个活动时遇到空指针异常
这是我的代码下面
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
System.out.println(requestCode + ", " + resultCode);
if (requestCode == SELECT_PICTURE) {
if (data.getData() != null) {
Uri selectedImageUri = data.getData();
String path = getPath(selectedImageUri);
System.out.println("PATH = "+path);
Intent _intent = new Intent(MainActivity.this,AndroidFaceDetector.class);
_intent.putExtra("mypath", path);
startActivityForResult(_intent, CROPPED_FACE_IMAGE);
}
else
{
Toast.makeText(MainActivity.this, "Please try again", Toast.LENGTH_SHORT).show();
}
}
else {
setImage(data);
}
}
}
现在在 AndroidFaceDetector 类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new myView(this));
Intent _intent = getIntent();
path = _intent.getStringExtra("mypath");
System.out.println("Path is gettting "+path); //here i am getting null value
}
因为
在这里,我得到的路径值为 null.. 任何机构都可以解决这个问题....