在Android中,Activity允许有很多种调用方式,其中一个方法是使用 <intent-filter>。

比如:

<intent-filter>      <action android:name="android.intent.action.VIEW" />      <category android:name="android.intent.category.DEFAULT" />      <category android:name="android.intent.category.BROWSABLE" />      <data          android:host="www.google.com"          android:path="m/products/scan"          android:scheme="http" />  </intent-filter>  


一开始我以为,在浏览器中键入“http://www.google.com/m/products/scan”就可以调用了的,结果发现浏览器只是正常打开它 T.T
后来发现,它的调用仍然需要使用intent

Uri uri = Uri.parse("http://www.google.com/m/products/scan");  Intent it = new Intent(Intent.ACTION_VIEW, uri);  startActivity(it);  


我是在一个Button的onClick()方法里写的这些代码,这样按这个按钮,就会调用所有符合要求的含有对应<intent-filter>的Activity,在我的手机里,有Chrome Beta、浏览器、快拍二维码、条码扫描器,以及我刚刚创建那个应用的Activity。

嗯嗯,记录一下,以后会经常把日常遇到的问题记下来,方便遇到同样问题的开发者们一起学习!

by HADB of HAOest

2012-6-18 23:13 于宿舍

更多相关文章

  1. android倒计时(整理)
  2. 手工下载android sdk或者system images等等
  3. android源码分析(一) - 语言切换机制
  4. Android调用摄像头闪退
  5. Android(安卓)设置隐式意图
  6. android scroller类的使用
  7. Android(安卓)进度条
  8. Android横竖屏切换总结(Android资料收藏)
  9. vue.js的h5页面与android(WebViewJavascriptBridge) / ios(windo

随机推荐

  1. Android实现检测耳机插入和拔出
  2. Android:Actionbar的显示和隐藏
  3. Android CTS 问题分析
  4. 360加固保加固的安卓/Android包,重金求APP
  5. Qt on Android Episode 2(翻译)
  6. Android 快速开发框架 ThinkAndroid
  7. Android完整的app项目
  8. 《Android》Lesson08-Activity的生命周期
  9. Android(安卓)TableLayout
  10. android,JNI创建进程,使用fork()