Intent调用其他应用setComponent启动其他应用程序
来源:互联网 发布:手机怎么安装java微信 编辑:程序博客网 时间:2024/05/02 01:35
[Intent] 调用其他应用 setComponent
資料來源:http://slashgill.blogspot.com/2010/10/intent.html
只要利用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启动另外一个程序
只要利用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启动另外一个程序
- Intent调用其他应用setComponent启动其他应用程序
- [Intent] 调用其他应用 setComponent
- [Intent] 调用其他应用 setComponent
- Android Intent 调用其他应用 setComponent
- Android Intent 调用其他应用 setComponent
- 通过Intent中的setComponent来启动其他应用中的Service
- intent 启动其他应用程序应用
- android 调用启动其他应用
- 启动调用其他应用程序的方法
- Android应用如何启动其他应用程序
- android里 通过Intent来启动其他非系统应用程序
- android 在应用中启动其他应用Intent的写法
- IOS--启动其他应用程序
- IOS--启动其他应用程序
- IOS启动其他应用程序
- 启动其他应用程序
- Delphi调用其他应用程序
- Android中通过Intent调用其他应用的方法
- 详解Spring
- cocos2d-x 安卓环境配置 -转
- Dynamic Memory Allocation in Critical Embedded Systems/关于嵌入式系统中的动态内存分配
- mybatis 查询结果集的配置
- Spring-3.2.4 + Quartz-2.2.0集成实例
- Intent调用其他应用setComponent启动其他应用程序
- eclipse git插件配置
- android整合--fragment
- Git 服务器在Ubuntu12.04上的搭建与使用体验第一篇
- 2013杭州网络赛C题HDU 4640(模拟)
- Spring 3.x企业应用开发实战(3)----资源抽象接口
- c语言面试常见问题
- poj1001
- 来北京两个月-发发牢骚