Android Intent 调用其他应用 setComponent
https://blog.csdn.net/muojie/article/details/7932024
只要利用adb logcat ,再搭配使用setComponet(),就可以轻易的呼叫第三方程式(不在自己的application内)。
详细用法参考原文:
https://developer.android.com/reference/android/content/Intent.html#setComponent%28android.content.ComponentName%29
比如我自己的程式想执行Android里面的Settings,先用adb logcat看系统是如何呼叫Settings的
I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10200000 cmp=com.android.settings/.Settings }
I/ActivityManager( 60): Displayed activity com.android.settings/.Settings: 1205 ms (total 1205 ms)
只要有这个cmp就可以呼叫Settings了
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = new Intent();
ComponentName comp = new ComponentName("com.android.settings", "com.android.settings.Settings");
i.setComponent(comp);
startActivity(i);
}
}
另外有些程式要被执行,Intent还要多加搭配Intent.setData()或者是Intent.setAction()等方式。比如:想要开启Browser,而且是开启tw.yahoo.com的网页,程式码如下:
Intent i = new Intent();
ComponentName comp = new ComponentName("com.android.browser", "com.android.browser.BrowserActivity");
i.setComponent(comp);
Uri uri = Uri.parse("https://tw.yahoo.com");
i.setData(uri);
startActivity(i);
参考:
最后更新:2017-04-03 14:54:36
上一篇:
剑指Offer之和为S的连续正数序列
下一篇:
史上最全的android学习资料
【java】split字符串分割
现代医学影像在肿瘤诊治中的应用
百度产品经理探秘:需求把握和正确决策
Installation and Operation Guide for BigBench on MaxCompute Benchmarking Suite
Android数据库(SqlLite)操作和db文件查看
这四十年来的香港歌坛在唱些什么,“南中国听歌最多”的数据分析师带你一探究竟
如何将MySQL GR 设置为多主模式
C#移位运算(左移和右移)
阿里云虚拟主机+wordpress建站教程 阿里云虚拟主机+wordpress建站教程
剖析Disruptor:为什么会这么快?(三)揭秘内存屏障