Android应用打开另一个应用程序

在程序开发过程当中,常遇到需要启动另一个应用程序的情况,比如在点击软件的一个按钮可以打开地图软件。

如果既有包名又有主类的名字,那就好 办了,

直接像下面就行:

Intent intent = new Intent(Intent.ACTION_MAIN); 
intent.addCategory(Intent.CATEGORY_LAUNCHER);             
ComponentName cn = new ComponentName(packageName, className);             
intent.setComponent(cn); 
startActivity(intent); 
在代码中"packageName" 是要打开的程序包名," className"是要打开的Activity。

或者这样:

Intent intent = new Intent(); 

PackageManager packageManager = this.getPackageManager(); 

intent = packageManager.getLaunchIntentForPackage(packageName); 

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP) ; 

this.startActivity(intent);
例子:程序中调用浏览器,代码如下:
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://blog.cndn.net/zml_2015")); 
    startActivity(intent);
 

下面是收集的一些APP的包名和Activity入口;
com.andrew.apollo.ui.activities.HomeActivity                                CM 音乐apollo
com.bel.android.dspmanager.activity.DSPManager                        DSP管理器
com.android.vending.AssetBrowserActivity                                   google play 商店
com.uucun.android.cms.activity.MarketLoginAndRegisterActivity     魔趣市场
com.android.contacts.DialtactsActivity                                          拨号
com.android.gallery3d.app.GalleryActivity                                     图库
com.lbe.security.ui.SplashActivity                                                 LBE安全大师
com.cyanogenmod.filemanager.activities.NavigationActivity            CM 文件管理器
com.UCMobile.main.UCMobile                                                      UC浏览器
com.tencent.mobileqq.activity.SplashActivity                                  QQ
com.tencent.mtt.SplashActivity                                                     QQ浏览器
com.android.stk.stksettings                                                         SIM卡工具包
com.android.providers.downloads.ui.DownloadList                         下载
com.sds.android.ttpod.EntryActivity                                              天天动听
com.android.soundrecorder.SoundRecorder                                   录音机
com.android.phone.EmergencyDialer                                            手机
net.cactii.flash2.MainActivity                                                        手电筒
com.android.calendar.AllInOneActivity                                           日历
com.android.deskclock.DeskClock                                                  时钟
com.qqgame.hlddz.hlddzActivity                                                   QQ欢乐斗地主
com.android.browser.BrowserActivity                                            浏览器
com.android.email.activity.Welcome                                              Email
com.baidu.input.ImemainConfigActivity                                         百度输入法
com.android.camera.CameraLauncher                                           相机
com.android.mms.ui.ConversationList                                            信息
com.android.contacts.activities.PeopleActivity                                 联系人
com.qq.ac.android.activity.SPlashActivity                                        腾讯微漫
com.android.calculator2.Calculator                                                计算器
com.android.settings.Settings                                                        设置
com.mfunz.bbs.net.discuz.one.activity.SplashActivity                        魔趣论坛

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值