Android -- 分享功能和打开指定程序

时间:2023-03-09 00:24:38
Android -- 分享功能和打开指定程序

打开指定程序                                                                               

Intent intent = new Intent();
ComponentName cmp = new ComponentName("com.sina.weibo","com.sina.weibo.EditActivity");
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(cmp);
startActivityForResult(intent, 0);

另:几个常用的Package命令:

新浪微博(编辑界面):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

分享                                                                                           

Intent intent=new Intent(Intent.ACTION_SEND);   

intent.setType("text/plain");   

intent.putExtra(Intent.EXTRA_SUBJECT,"分享");
intent.putExtra(Intent.EXTRA_TEXT, "hello,weibo!");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(intent, "share"));

其中 intent.putExtra(Intent.EXTRA_TEXT, "hello,weibo!");

我是天王盖地虎的分割线                                                                 

相关文章