工程结构

//效果图

点击测试分享                                                                                                          点击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>

//代码如下:

  1. package com.mark.share.demo;
  2. import java.io.File;
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.net.Uri;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.Button;
  10. public class AppShareDemoActivity extends Activity
  11. {
  12. private Button testshare;
  13. private Button createChooserBtn;
  14. @Override
  15. public void onCreate(Bundle savedInstanceState)
  16. {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.main);
  19. testshare=(Button) findViewById(R.id.testshare);
  20. createChooserBtn=(Button) findViewById(R.id.Test_createChooser);
  21. testshare.setOnClickListener(new OnClickListener()
  22. {
  23. @Override
  24. public void onClick(View v)
  25. {
  26. Intent intent = new Intent(Intent.ACTION_SEND);
  27. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  28. intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("sdcard/1.png")));  //传输图片或者文件 采用流的方式
  29. intent.putExtra(Intent.EXTRA_TEXT, "分享分享微博");   //附带的说明信息
  30. intent.putExtra(Intent.EXTRA_SUBJECT, "标题");
  31. intent.setType("image/*");   //分享图片
  32. startActivity(Intent.createChooser(intent,"分享"));
  33. }
  34. });
  35. createChooserBtn.setOnClickListener(new OnClickListener()
  36. {
  37. @Override
  38. public void onClick(View v)
  39. {
  40. Intent intent = new Intent();
  41. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  42. intent.setAction("android.intent.action.XXMM");
  43. intent.setDataAndType(Uri.parse("file:///sdcard/DCIM/cc.mp3"), "mark/nimei");
  44. startActivity(Intent.createChooser(intent, "Select music1 app"));
  45. }
  46. });
  47. }
  48. }

Android调用系统分享功能以及createChooser的使用的更多相关文章

  1. android - 调用系统分享功能分享图片

    step1: 编写分享代码, 将Uri的生成方式改为由FileProvider提供的临时授权路径,并且在intent中添加flag 注意:在Android7.0之后,调用系统分享,传入URI的时候可能 ...

  2. Android调用系统分享功能总结

    Android分享-调用系统自带的分享功能 实现分享功能的几个办法 1.调用系统的分享功能 2.通过第三方SDK,如ShareSDK,友盟等 3.自行使用各自平台的SDK,比如QQ,微信,微博各自的S ...

  3. Android 调用系统分享文字、图片、文件,可直达微信、朋友圈、QQ、QQ空间、微博

    原文:Android 调用系统分享文字.图片.文件,可直达微信.朋友圈.QQ.QQ空间.微博 兼容SDK 18以上的系统,直接调用系统分享功能,分享文本.图片.文件到第三方APP,如:微信.QQ.微博 ...

  4. Android调用系统相机功能

    在常规应用开发过程中,我们经常会使用到手机的相机功能,通过调用系统相机方便快捷的帮助我们实现拍照功能,本篇我将带领大家实现一下,如何通过调用系统相机实现拍照. 第一种:调用系统相机拍照,通过返回的照片 ...

  5. Java乔晓松-android中调用系统拍照功能并显示拍照的图片

    android中调用系统拍照功能并显示拍照的图片 如果你是拍照完,利用onActivityResult获取data数据,把data数据转换成Bitmap数据,这样获取到的图片,是拍照的照片的缩略图 代 ...

  6. Android调用系统相册和拍照的Demo

    最近我在群里看到有好几个人在交流说现在网上的一些Android调用系统相册和拍照的demo都有bug,有问题,没有一个完整的.确实是,我记得一个月前,我一同学也遇到了这样的问题,在低版本的系统中没问题 ...

  7. Android调用系统相机、自己定义相机、处理大图片

    Android调用系统相机和自己定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,而且因为涉及到要把拍到的照片显示出来,该样例也会涉及到Android载入大图片时候的处 ...

  8. Android调用系统相机、自定义相机、处理大图片

    Android调用系统相机和自定义相机实例 本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显示出来,该例子也会涉及到Android加载大图片时候的处理 ...

  9. 探索Android调用系统的分享功能

    非常多的应用为了应用的推广和传播都会使用"分享"的功能,点击分享button.就能将想要分享的内容或者图片分享至QQ空间.微博.微信朋友圈等实现了分享功能的应用.这篇文章主要是为了 ...

随机推荐

  1. 2016-1-7第一个完整APP 私人通讯录的实现 5:保存数据

    一:登陆界面 1):用户点击登陆按钮并成功登陆后,根据此时的开关情况选择是否保存数据,代码如下: "]) { [self performSegueWithIdentifier:@" ...

  2. Apache与Nginx的区分比较

    什么是Nginx代理代理服务器,它和Apache相比又有什么区别呢?你又该如何选择使用呢,用其中一个还是两者都用?我们将会在这里探索一下这些问题的答案. Apache服务器从1995年就开始使用了.相 ...

  3. python03函数、递归

    本节内容 1. 函数基本语法及特性 2. 参数与局部变量 3. 返回值 4.递归 5.匿名函数 6.函数式编程介绍 7.高阶函数 8.内置函数 1.函数基本语法及特性 函数是什么? 函数一词来源于数学 ...

  4. AFNetworking实现程序重新启动时的断点续传

    今天需要用AFNetworking实现断点续传的功能,但是在进行了一番研究之后,发现AFNetworking虽然支持下载文件的暂停和继续,但是程序重新启动后再次下载无法进行续传.网上有说可以通过AFD ...

  5. 计算几何----判断空间点是否在一个四面体(tetrahedron)内部

    DESCRIPTION: 判断空间点 P(x, y, z)是否在一个四面体的内部? Let the tetrahedron have vertices V1 = (x1, y1, z1) V2 = ( ...

  6. js中的apply调用

    今天看了阮一锋老师的一篇文章,感觉很明了对闭包的理解,尤其是文章中的apply的介绍 apply()是函数对象的一个方法,它的作用是改变函数的调用对象,它的第一个参数就表示改变后的调用这个函数的对象. ...

  7. Kylin上chromium不能用flash的解决命令

    sudo apt-get update sudo apt-get install pepperflashplugin-nonfree sudo update-pepperflashplugin-non ...

  8. [转】HTTP请求流程(二)----Telnet模拟HTTP请求

    转自: http://www.cnblogs.com/stg609/archive/2008/07/06/1237000.html 上一部分"流程简介", 我们大致了解了下HTTP ...

  9. D - 排列

    #include<cstdio> #include<algorithm> #include<string.h> using namespace std; #defi ...

  10. nginx的启动,停止命令

    停止操作停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的步骤1:查询nginx主进程号ps -ef | grep nginx在进程列表里 面找master进程,它的编 ...