在我的片段我已经开始startActivityforresult意图进行照片capture.I在片段类已重写onActivityResult回调方法。 我已经实现onActivityResult回调在主要活动中一些其他的意图。 我的问题是片段onActivityResult执行调用活动onActivityResult方法,并返回空指针异常后。 片段onactivityresult方法
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK)
{
prof_bitmap = null;
if (requestCode == 0)
{
Log.e("" ,"entered activity Result Code 0");
Uri photoUri = data.getData();
if (photoUri != null)
{
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getActivity().getContentResolver().query(
photoUri, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
Log.e("" ,"File Path" +filePath);
prof_bitmap = setImage(filePath);
}
}
if (requestCode == 1)
{
Log.e("" ,"entered activity Result Code 1");
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
prof_bitmap = bitmap;
Log.e("" ,"entered activity Result Code 1"+bitmap);
profile_pic.setImageBitmap(bitmap);
}
}
}
活动onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
Log.e("" ,"called onActivityResult in main");
Session.getActiveSession().onActivityResult(this, requestCode,
resultCode, data);
}
如何只调用片段onactivityresult方法?
MY logcat的
失败递送结果ResultInfo {谁= NULL,请求= 1,结果= -1,数据=意向{ACT =直列数据DAT =内容://媒体/外部/图像/媒体/ 222(具有额外)}}到活动{com.mobiotics.tvbuddydemo / com.mobiotics.tvbuddydemo.TVBuddyMainActivity}:显示java.lang.NullPointerException