启动应用代码!Intent intent = new Intent();ComponentName cmp = new ComponentName(com.tencent.mm,com.tencent.mm.ui.LauncherUI);intent.setAction(Intent.A
如何在自己程序跳转至微信,新浪,腾讯微博,,QQ空间等
分类: android基础修炼
微信跳转
跳转启动应用代码!
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 ) ;新浪微博(编辑界面):com.sina.weibo com.sina.weibo.EditActivity
腾讯微博(编辑界面):com.tencent.WBlog com.tencent.WBlog.activity.MicroblogInput
微信: com.tencent.mm com.tencent.mm.ui.LauncherUI
QQ: com.tencent.mobileqq com.tencent.mobileqq.activity.HomeActivity
替换就OK了!
//-----------------------------------------------------------------------------------------------------------------------
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName("com.tencent.mm","com.tencent.mm.ui.LauncherUI"));
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "未安装微信", Toast.LENGTH_SHORT).show();
}
亲测有效,对于没有安装微信应用的,会报have you declared this activity in your AndroidManifest.xml错误。