首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android中施用代码启动其他程序

2012-09-27 
android中使用代码启动其他程序你要訪問其他的程序,那麼這個程序要先裝載到模擬器或真機上面,因為我們要使

android中使用代码启动其他程序
你要訪問其他的程序,那麼這個程序要先裝載到模擬器或真機上面,因為我們要使用要訪問其他程序的包。

簡單的訪問有以下兩種方式(目前只知道這兩種):

一、使用Intent的setComponent方法

二、使用包管理器

一、使用Intent的setComponent方法

Intent intent = new Intent();

intent.setComponent(new ComponentName("包名", "包名.主類名"));

intent.setAction(Intent.ACTION_VIEW);

startActivity(intent);

二、使用包管理器

Intent intent = new Intent();

intent = getPackageManager().getLaunchIntentForPackage("包名");

startActivity(intent);

热点排行