Android 实现分享功能代码
2013-11-14 09:19
666 查看
首先新建share.xml布局文件 [html] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/share" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="分享" /> </LinearLayout> 然后是新建Activity [java] /** * ShareActivity.java * 版权所有(C) 2012 * 创建:cuiran 2012-10-17 上午9:23:05 */ package com.cayden.citygirl.activity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; /** * TODO * @author cuiran * @version TODO */ public class ShareActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.share); Button share=(Button)this.findViewById(R.id.share); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_SUBJECT, "Share"); intent.putExtra(Intent.EXTRA_TEXT, "I have successfully share my message through my app (分享自city丽人馆)"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, getTitle())); } }); }
相关文章推荐
- 用HTML+JS实现Android闹钟功能,附带Alarm代码分享
- Android实现截图和分享功能的代码
- android 分享功能,实现分享的程序与进行分享信息的代码
- 【源码】实现Android闹钟功能使用HTML+JS,并附带Alarm代码分享
- Android 分享功能的实现代码
- Cocos2d-x3.3RC0通过JNI调用Android的Java层代码,实现分享功能
- 【源码】实现Android闹钟功能使用HTML+JS,并附带Alarm代码分享
- Android中实现下载和解压zip文件功能代码分享
- Android 分享功能的实现
- Angular实现下载安装包的功能代码分享
- Android应用自动更新功能的代码实现(转)
- Android应用自动更新功能的代码实现
- Android应用自动更新功能的代码实现
- Android多线程断点续传下载功能实现代码
- Android如何实现分享功能
- 【Android】Scrollview返回顶部,快速返回顶部的功能实现,详解代码。
- Android用代码实现GPS的开启/关闭功能+网络开关
- Android应用自动更新功能的代码实现
- Android 分享功能的实现
- android 同时实现微信分享和微信登录功能