前面有一篇博客说了使用QQ登录并获取用户QQ信息,也实现了分享消息到QQ功能,前面一篇博客使用的是腾讯QQ的开放接口,而且使用腾讯开放接口分享消息到QQ,不能分享纯文本信息,这个看了官方的API就知道了!
下面介绍另一种方法,不用使用什么开放接口,直接使用系统的就可以,并且可以分享纯文本信息!
一、直接将消息分享到QQ:
package com.example.demo3;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void shareToQQ(View view){
shareQQ(MainActivity.this);
}
public void shareQQ(Context mContext) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "这是要分享的消息");
sendIntent.setType("text/plain");
try {