`

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);
分享到:
评论
1 楼 再度重相逢 2011-11-10  

相关推荐

Global site tag (gtag.js) - Google Analytics