Android分享到腾讯微博,信息,新浪微博等等,的实现方式

简介:

http://www.cnblogs.com/hzl512/archive/2012/04/12/2444033.html

效果图:

 

 

 xml

<?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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/btnFenXiang"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="分享" />

</LinearLayout>

package hzl.pak.UI;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class FenxiangActivity extends Activity {
    private Button btnFenXiang = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnFenXiang = (Button) findViewById(R.id.btnFenXiang);
        btnFenXiang.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_SEND); //启动分享发送的属性
                intent.setType("text/plain");                                    //分享发送的数据类型
                intent.putExtra(Intent.EXTRA_SUBJECT, "subject");    //分享的主题
                intent.putExtra(Intent.EXTRA_TEXT, "extratext");    //分享的内容
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//这个也许是分享列表的背景吧
                FenxiangActivity.this.startActivity(Intent.createChooser(intent, "分享"));//目标应用选择对话框的标题
            }
        });
    }

}


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="hzl.pak.UI"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".FenxiangActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            <intent-filter android:label="@string/albums_sendbyWBlog">
                <action android:name="android.intent.action.SEND" />
                <data android:mimeType="image/*" />                
         <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
                
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

注意配置文件里面的:

            <intent-filter android:label="@string/albums_sendbyWBlog">
                <action android:name="android.intent.action.SEND" />
                <data android:mimeType="image/*" />                
         <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

据说没这个腾讯微薄的不会出来,这个是网上别人反编译过的代码。



相关文章
|
4月前
|
XML Java Android开发
Android App开发网络通信中使用okhttp下载和上传图片、文件讲解及实战(超详细实现用户注册信息上传 附源码)
Android App开发网络通信中使用okhttp下载和上传图片、文件讲解及实战(超详细实现用户注册信息上传 附源码)
142 0
|
4月前
|
数据库 Android开发
Android Studio开发之应用组件Application的讲解及实战(附源码,通过图书管理信息系统实战)
Android Studio开发之应用组件Application的讲解及实战(附源码,通过图书管理信息系统实战)
51 0
|
4月前
|
XML Java Android开发
Android Studio开发之使用内容组件Content获取通讯信息讲解及实战(附源码 包括添加手机联系人和发短信)
Android Studio开发之使用内容组件Content获取通讯信息讲解及实战(附源码 包括添加手机联系人和发短信)
88 0
|
9月前
|
IDE 数据可视化 Java
Android自动生成代码,可视化脚手架之基础信息配置
今天的内容比较简单,大致过一下Electron一些基本用法,虽然说这些比较简单,但又是不得不去了解的,正如做Android的我们,也不是一上来就会的,需要一个循序渐进的过程,下一章,我们再去实际的开发功能。
135 0
|
3天前
|
测试技术 Android开发
Android App获取不到pkgInfo信息问题原因
Android App获取不到pkgInfo信息问题原因
14 0
|
4月前
|
XML Java Android开发
Android Studio App开发之通知推送Notification的讲解及实战(给用户推送信息实战)
Android Studio App开发之通知推送Notification的讲解及实战(给用户推送信息实战)
158 0
|
2月前
|
数据库 Android开发 数据库管理
【Android】使用android studio查看内置数据库信息
【Android】使用android studio查看内置数据库信息
74 0
|
7月前
|
Android开发
Android系统开发中产品信息文件说明
Android系统开发中产品信息文件说明
80 1
|
3月前
|
开发工具 Android开发
Android获取SDK的版本信息
Android获取SDK的版本信息
39 0
|
4月前
|
Java 定位技术 Android开发
【Android App】利用腾讯地图获取地点信息和规划导航线路讲解及实战(附源码和演示视频 超详细必看)
【Android App】利用腾讯地图获取地点信息和规划导航线路讲解及实战(附源码和演示视频 超详细必看)
65 1