且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-09-02 19:43:20


打开指定程序                                                                               

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);
Android -- 分享功能和打开指定程序

另:几个常用的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

分享                                                                                           

Android -- 分享功能和打开指定程序
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"));
Android -- 分享功能和打开指定程序

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

我是天王盖地虎的分割线                                    




本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3888189.html,如需转载请自行联系原作者