Android调用系统分享功能以及createChooser的使用
工程结构
//效果图
点击测试分享 点击createChoose妙用
主要是看右边的,可不是用什么Dialog来搞的哦,而是你Activity程序,可以激活进去了
提示:这个东西可以延伸到一个音频文件,打开时,可以调用你的音乐播放器来播放哦,视频,图片,也是类似,可以调用你自己的东西
当然,前提是你的manifest.xml里的东西要配置对呀
<data Android:mimeType="mark/nimei" />
如下
<activity android:name=".TestActivity"
android:label="你妹啊"
>
<intent-filter>
<action android:name="android.intent.action.XXMM" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="mark/nimei" />
</intent-filter>
</activity>
<activity android:name=".Test2Activity"
android:label="你妹啊2"
>
<intent-filter>
<action android:name="android.intent.action.XXMM" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="mark/nimei" />
</intent-filter>
</activity>
//代码如下:
- package com.mark.share.demo;
- import java.io.File;
- import android.app.Activity;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- public class AppShareDemoActivity extends Activity
- {
- private Button testshare;
- private Button createChooserBtn;
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- testshare=(Button) findViewById(R.id.testshare);
- createChooserBtn=(Button) findViewById(R.id.Test_createChooser);
- testshare.setOnClickListener(new OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("sdcard/1.png"))); //传输图片或者文件 采用流的方式
- intent.putExtra(Intent.EXTRA_TEXT, "分享分享微博"); //附带的说明信息
- intent.putExtra(Intent.EXTRA_SUBJECT, "标题");
- intent.setType("image/*"); //分享图片
- startActivity(Intent.createChooser(intent,"分享"));
- }
- });
- createChooserBtn.setOnClickListener(new OnClickListener()
- {
- @Override
- public void onClick(View v)
- {
- Intent intent = new Intent();
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setAction("android.intent.action.XXMM");
- intent.setDataAndType(Uri.parse("file:///sdcard/DCIM/cc.mp3"), "mark/nimei");
- startActivity(Intent.createChooser(intent, "Select music1 app"));
- }
- });
- }
- }
Android调用系统分享功能以及createChooser的使用的更多相关文章
- android - 调用系统分享功能分享图片
step1: 编写分享代码, 将Uri的生成方式改为由FileProvider提供的临时授权路径,并且在intent中添加flag 注意:在Android7.0之后,调用系统分享,传入URI的时候可能 ...
- Android调用系统分享功能总结
Android分享-调用系统自带的分享功能 实现分享功能的几个办法 1.调用系统的分享功能 2.通过第三方SDK,如ShareSDK,友盟等 3.自行使用各自平台的SDK,比如QQ,微信,微博各自的S ...
- Android 调用系统分享文字、图片、文件,可直达微信、朋友圈、QQ、QQ空间、微博
原文:Android 调用系统分享文字.图片.文件,可直达微信.朋友圈.QQ.QQ空间.微博 兼容SDK 18以上的系统,直接调用系统分享功能,分享文本.图片.文件到第三方APP,如:微信.QQ.微博 ...
- Android调用系统相机功能
在常规应用开发过程中,我们经常会使用到手机的相机功能,通过调用系统相机方便快捷的帮助我们实现拍照功能,本篇我将带领大家实现一下,如何通过调用系统相机实现拍照. 第一种:调用系统相机拍照,通过返回的照片 ...
- Java乔晓松-android中调用系统拍照功能并显示拍照的图片
android中调用系统拍照功能并显示拍照的图片 如果你是拍照完,利用onActivityResult获取data数据,把data数据转换成Bitmap数据,这样获取到的图片,是拍照的照片的缩略图 代 ...
- Android调用系统相册和拍照的Demo
最近我在群里看到有好几个人在交流说现在网上的一些Android调用系统相册和拍照的demo都有bug,有问题,没有一个完整的.确实是,我记得一个月前,我一同学也遇到了这样的问题,在低版本的系统中没问题 ...
- Android调用系统相机、自己定义相机、处理大图片
Android调用系统相机和自己定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,而且因为涉及到要把拍到的照片显示出来,该样例也会涉及到Android载入大图片时候的处 ...
- Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显示出来,该例子也会涉及到Android加载大图片时候的处理 ...
- 探索Android调用系统的分享功能
非常多的应用为了应用的推广和传播都会使用"分享"的功能,点击分享button.就能将想要分享的内容或者图片分享至QQ空间.微博.微信朋友圈等实现了分享功能的应用.这篇文章主要是为了 ...
随机推荐
- operation not possible due to RF-kill
使用mdk3时出现这个问题operation not possible due to RF-kill 就是输入第一条命令 后出现 operation not possible due to RF-ki ...
- Oracle排序问题
关于oracle排序的几点认识: (1)oracle本身不具有任何默认排序功能,要想排序,必须使用order by,而order by后的数据行默认是asc(升序排列),要降序选择desc : (2) ...
- AppCan相关网站
AppCan文档中心: http://doc.appcan.cn/#!/guide/handbook AppCan官网: http://www.appcan.cn/index.html
- PHP安装编译配置参考
编辑安装php的参考配置: ./configure --prefix=/usr/local/php-5.6.8 --with-config-file-path=/usr/local/php-5.6.8 ...
- python解析smart结构数据
python编程解析如下smart结构数据,得到一行smart信息 run: smartctl -a /dev/sda out: smartctl 6.3 2014-07-26 r3976 [x86_ ...
- python矩阵运算 不断收集整理
python矩阵运算 转自:http://blog.sina.com.cn/s/blog_5f234d4701012p64.html Python使用NumPy包完成了对N-维数组的快速便捷操作.使用 ...
- CentOS 6.6 中设置Terminal快捷键
排版比较乱,参见 https://www.zybuluo.com/Jpz/note/144583 CentOS 6.6 中设置Terminal快捷键 Linux开发环境配置 Terminal是Cent ...
- SQL参数化查询--最有效可预防SQL注入攻击的防御方式
参数化查询(Parameterized Query 或 Parameterized Statement)是访问数据库时,在需要填入数值或数据的地方,使用参数 (Parameter) 来给值. 在使用参 ...
- ztong上机3
二.实验名称:数字图像处理matlab上机 三.实验学时:2学时 四.实验目的:(详细填写) 掌握几何变换 掌握插值 理解配准的概念 五.实验内容 (1)首先自己写一个对图像进行旋转和缩放的复合变换程 ...
- mybatis+spring的简单介绍学习
参考下面链接 http://mybatis.github.io/spring/zh/index.html