我想从我正在开发的应用程序发送图像,我有下面的代码,但坚持如何从我的/可绘制文件夹中的文件创建Uri,任何想法? (在这一点上很困惑)Android ShareActionProvider图像问题
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.second, menu);
MenuItem shareitem = menu.findItem(R.id.menu_item_share);
myShareActionProvider = (ShareActionProvider) shareitem.getActionProvider();
myShareActionProvider.setShareIntent(createShareIntent());
ActionBar actionBar = getActionBar();
actionBar.show();
return true;
}
public Intent createShareIntent() {
image = ???
Uri uri = Uri.fromFile(image);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/png");
return shareIntent;
}
非常感谢,我只是想通了这一点,这个解决方案的工作虽然:) –