我有一个片段,调用从图库选择图像的意图,如下所示:
Intent intent=new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Complete Action Using"),1);
我成功执行了上述方法,它可以启动手机相册并从中选择图像,但是应用程序应该返回到调用的片段,但它没有,即使我可以在LogCat中看到onActivityonResult的调用。
我还有一个从地图获取位置的函数,它会返回到调用的片段,但是当选择图像时,我没有回到调用的活动,而是首先显示父活动的第一个片段。
这是我的onActivityResult:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==1 && resultCode==getActivity().RESULT_OK){
Log.d(TAG,"Request Code is 1 Running: "+requestCode+" "+resultCode);
Uri imageNameURL=data.getData();
Log.d(TAG,imageNameURL.toString());
ImagePath=getPath(imageNameURL);
Log.d(TAG,"onActivityResult "+ImagePath);
bitmap= BitmapFactory.decodeFile(ImagePath);
}
else if (requestCode==2 && resultCode==getActivity().RESULT_OK){
Log.d(TAG,"Request Code 2 Running");
LatLngBounds LL= PlacePicker.getLatLngBounds(data);
double lat=LL.northeast.latitude;
double longi=LL.northeast.longitude;
double lat2=LL.southwest.latitude;
double longi2=LL.southwest.longitude;
}
}