1.打开微信
try {
Intent intent = new Intent();
ComponentName cmp = new ComponentName("com.tencent.mm","com.tencent.mm.ui.LauncherUI");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(cmp);
startActivityForResult(intent, 0);
} catch (Exception e) {
Toast.makeText(context, "您的手机未安装微信!", Toast.LENGTH_SHORT).show();
}
另:新浪微博:com.sina.weibo com.sina.weibo.EditActivity
腾讯微博:com.tencent.WBlog com.tencent.WBlog.activity.MicroblogInput
QQ: com.tencent.mobileqq com.tencent.mobileqq.activity.HomeActivity
2.调用QQ聊天
- String qq="111111";(这里写要调用的QQ号)
- String url="mqqwpa://im/chat?chat_type=wpa&uin="+qq;
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));