Android调用系统分享功能以及createChooser的使用
来源:互联网 发布:q币赚钱软件 编辑:程序博客网 时间:2024/04/30 17:03
原文: http://blog.csdn.net/yanglian20009/article/details/7592117
工程结构
//效果图
点击测试分享 点击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调用系统分享功能以及createChooser的使用
- Android调用系统分享功能以及createChooser的使用
- android 调用系统分享功能以及实现自定义分享
- 探索Android调用系统的分享功能
- Android调用系统本身的分享功能
- Android 调用系统的分享功能
- 探索Android调用系统的分享功能
- Android:调用系统分享功能
- Android:调用系统分享功能
- Android:调用系统分享功能
- Android分享---调用系统自带的分享功能
- android开发中调用系统中分享功能的方法
- android 调用系统中分享功能
- 调用系统分享功能
- 调用系统分享功能
- 调用系统分享功能
- Android调用系统的相机,图库,以及裁剪图片功能。
- js一百零一夜之第二夜-js获取外部css样式
- 最近看到或是总结的一些观点
- HOJ 1496 World Cup Noise
- 《代码大全》读书笔记三
- 学习札记--Struts1 文件上传
- Android调用系统分享功能以及createChooser的使用
- HOJ 1459 Goldbach's Conjecture
- 对我启示的几句话
- Project Euler 45
- C#字符串相关函数(持续更新,绝不TJ)
- TCP大并发短连接造成TIME_WAIT问题解决办法
- 什么是回调函数
- spring源码阅读之IOC2 欢迎点评参考
- Android 实现文件分享功能(共享多个文件)