使用IntentFilter的拨号程序
2011-05-05 21:48
295 查看
在需要添加的activity添加如下即可:
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
-------------------
根据之前对于IntentFilter的描述,从硬件键盘的拨号键启动程序需要我们在TinyDialer中加入一条新的IntentFilter。我们先来看看在AndroidManifest.xml中关于IntentFilter的描述是什么。
<intent-filter>
<action android:name="android.Intent.Action.MAIN" />
<category android:name="android.Intent.Category.LAUNCHER" />
intent-filter>
目前只有一条IntentFilter,它的动作名称是Action.MAIN,类别名称是Category.LAUNCHER。正是有了这条IntentFilter,TinyDialer的图标才出现在了应用程序选择的菜单里。
为了新加入拨号键启动TinyDialer,我们加入:
<intent-filter>
<action android:name="android.Intent.Action.CALL_BUTTON"/
<category android:name="android.Intent.Category.DEFAULT" />
intent-filter>
更改后的效果怎么样?当你按下键盘左下角绿色的拨号键时,系统会弹出一个窗口提醒用户,选择启动TinyDialer还是选择Android自带的拨号程序如图所示。
这 个例子很好地说明了隐式Intent的用法。TinyDialer声明自己的IntentFilter的行为是ACTION.CALL_BUTTON,以 后每次用户按下拨号键时,Android系统都会将拨号键的意图和所有声明过ACTION.CALL_BUTTON的IntentFilter进行比较, 然后将匹配的组件提供给用户选择。
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
-------------------
根据之前对于IntentFilter的描述,从硬件键盘的拨号键启动程序需要我们在TinyDialer中加入一条新的IntentFilter。我们先来看看在AndroidManifest.xml中关于IntentFilter的描述是什么。
<intent-filter>
<action android:name="android.Intent.Action.MAIN" />
<category android:name="android.Intent.Category.LAUNCHER" />
intent-filter>
目前只有一条IntentFilter,它的动作名称是Action.MAIN,类别名称是Category.LAUNCHER。正是有了这条IntentFilter,TinyDialer的图标才出现在了应用程序选择的菜单里。
为了新加入拨号键启动TinyDialer,我们加入:
<intent-filter>
<action android:name="android.Intent.Action.CALL_BUTTON"/
<category android:name="android.Intent.Category.DEFAULT" />
intent-filter>
更改后的效果怎么样?当你按下键盘左下角绿色的拨号键时,系统会弹出一个窗口提醒用户,选择启动TinyDialer还是选择Android自带的拨号程序如图所示。
这 个例子很好地说明了隐式Intent的用法。TinyDialer声明自己的IntentFilter的行为是ACTION.CALL_BUTTON,以 后每次用户按下拨号键时,Android系统都会将拨号键的意图和所有声明过ACTION.CALL_BUTTON的IntentFilter进行比较, 然后将匹配的组件提供给用户选择。
相关文章推荐
- 第5章 使用Intent和IntentFilter进行通信
- 使用SetUnhandledExceptionFilter转储程序崩溃时内存DMP .
- 安卓使用隐式Intent(intent-filter)从其他Activity返回MainActivity时,App停止运行,及使用intent步骤简介
- 使用intent跳转到系统应用中的拨号界面、联系人界面、短信界面及其他
- Android深入浅出系列之实例应用—开机就运行自定义的程序BroadcastReceiver和intent-filter的用法
- 【Android 开发教程】使用Intent-Filter
- 使用SetUnhandledExceptionFilter让程序优雅的崩溃
- [小代码]使用intent用默认的程序打开文件
- 使用SetUnhandledExceptionFilter和DebugMiniDumpFilter来使程序在崩溃时生成dump文件 .
- 使用极光推送时报错[AndroidUtil] AndroidManifest.xml missing intent filter for DaemonService
- Android学习13--使用Intent和IntentFilter进行通信
- 使用Filter统计Java(J2EE)的web程序http请求响应时间
- Intent-filter的使用
- [转]使用SetUnhandledExceptionFilter让程序优雅的崩溃
- Linux 使用pppd和ppp程序进行3G/4G拨号
- 使用SetUnhandledExceptionFilter转储程序崩溃时内存DMP
- 使用SetUnhandledExceptionFilter让程序优雅的崩溃
- 【求助】使用intent-filter跳转activity出错
- 使用Filter统计Java(J2EE)的web程序http请求响应时间
- Android开发中使用Intent跳转到系统应用中的拨号界面、联系人界面、短信界面