Android Action Bar

本文介绍了如何使用 Android 的 ShareActionProvider 进行文本和图片的分享操作。针对分享文字和图片提供了具体的 Intent 创建方法,并给出了实现代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://blog.youkuaiyun.com/yuxlong2010/article/details/9299507  Action Bar讲的够详细啦!

关于ShareActionProvider:

1。分享文字:http://www.tuicool.com/articles/mAR7Zb

    Intent intent = new Intent(Intent.ACTION_SEND);
     intent.putExtra(Intent.EXTRA_TEXT, "这里是要分享的文字");
     intent.setType("text/plain");
     Intent.createChooser(intent, "Share");
     return intent;

2。分享图片:APIDemo: app---->actionbar--->Action Provider

        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("image/*");
        Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        return shareIntent;

       inputStream = getResources().openRawResource(R.raw.robot);
            outputStream = openFileOutput(SHARED_FILE_NAME,
                    Context.MODE_WORLD_READABLE | Context.MODE_APPEND);
            byte[] buffer = new byte[1024];
            int length = 0;
            try {
                while ((length = inputStream.read(buffer)) > 0){
                    outputStream.write(buffer, 0, length);
                }
            } catch (IOException ioe) {
                /* ignore */
            }

 

 

转载于:https://my.oschina.net/u/1389206/blog/340493

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值