Android Intent 调用其他应用 setComponent
来源:互联网 发布:录制视频软件 知乎 编辑:程序博客网 时间:2024/05/22 14:53
http://blog.csdn.net/muojie/article/details/7932024
只要利用adb logcat ,再搭配使用setComponet(),就可以輕易的呼叫第三方程式(不在自己的application內)。
詳細用法參考原文:
http://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("http://tw.yahoo.com");
i.setData(uri);
startActivity(i);
参考:
android使用setComponent启动另外一个程序
- Android Intent 调用其他应用 setComponent
- Android Intent 调用其他应用 setComponent
- [Intent] 调用其他应用 setComponent
- [Intent] 调用其他应用 setComponent
- Intent调用其他应用setComponent启动其他应用程序
- 通过Intent中的setComponent来启动其他应用中的Service
- Android中通过Intent调用其他应用的方法
- Android中通过Intent调用其他应用的方法
- Android中通过Intent调用其他应用的方法
- Android中通过Intent调用其他应用的方法
- Intent setComponent使用
- intent.setComponent()方法
- Intent setClass and setComponent
- Android中通过Intent调用其他应用的方法(转)
- android 调用启动其他应用
- android 在应用中启动其他应用Intent的写法
- Android 系统应用调用,intent的使用
- Android 内部系统应用的调用Intent
- 浅谈Overload和Override的区别
- HTTP请求报文和HTTP响应报文
- 解读ENVI Services Engine云解决方案
- Repeater的嵌套
- Android线程学习(三)之AsyncTask
- Android Intent 调用其他应用 setComponent
- eclipse开发hadooop2.2.0程序
- 学习笔记:android关于xml文件的操作
- Java Web开发环境的搭建
- clr via C#笔记(4)
- 如何通过ADO获得Access数据库中的所有用户表和表信息
- 大数据:技术与应用实践指南(中国工程院院士倪光南倾情作序,雷万云、毛新生、段永朝、安晖联合力荐)
- 怎样编写Apple Push Notification服务器
- initrd网络转载