3
공유 시작 공급자가 응용 프로그램 시작시 이미지를 기대하기 때문에 null 포인터를 얻고 있습니다. 나는 단지 나중에 제공 할 수 있습니다.안드로이드 ShareAction Provider null 포인터
여기 내 코드입니다
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.menu, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri uri = Uri.fromFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),
getBitmapName()));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.mailSubject));
setShareIntent(shareIntent);
return true;
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
당신이 (onCreate''포함) 전체 코드를 게시 할 수 있습니다? NPE는 초기화가 완료되기 전에 호출되기 때문에'setShareIntent'가 트리거 될 수 있습니다. – dumbfingers
@vineet, 여기서 무슨 일이 있었는지 알아 냈습니까? –