PictureViewActivity.java 文件源码

java
阅读 46 收藏 0 点赞 0 评论 0

项目:rental-calc 作者:
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    getMenuInflater().inflate(R.menu.picture_view_menu, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.action_share);

    // Fetch ShareActionProvider
    ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    if (shareActionProvider == null)
    {
        Log.w(TAG, "Failed to find share action provider");
        return false;
    }

    if(imageFilename == null)
    {
        Log.w(TAG, "No receipt to share");
        return false;
    }

    Intent shareIntent = new Intent(Intent.ACTION_SEND);

    // Determine mimetype of image
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(imageFilename, opt);
    shareIntent.setType(opt.outMimeType);

    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imageFilename)));
    shareActionProvider.setShareIntent(shareIntent);

    return super.onCreateOptionsMenu(menu);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号