android IP拨号器
来源:互联网 发布:算法分析与设计答案 编辑:程序博客网 时间:2024/04/29 08:37
在有些app中,有IP拨号的功能,这个功能就是当我们打电话出去的时候,在电话基础上加些区号或者打长途的时候加上比如17951就可以省点话费,今天就模仿的实现下此功能.
我们知道在系统打电话出去时,系统是会发出一个广播的,然后获取刚拨打的电话号码,再在电话号码之前加上区号等等,就实现了IP拨号器
新建一个android项目 IPDialer
CallBroadcastReceiver.java广播接受者
public class CallBroadcastReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {Log.e("CallBroadcastReceiver","我是否执行了");String number = getResultData();setResultData("0571"+number);}}
因为广播也是四大组件之一,也必须在<span style="font: 24px/36px 楷体; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">AndroidManifest.xml 中注册,</span>
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ipdialer" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /><uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name="com.example.ipdialer.CallBroadcastReceiver" > <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL"/> </intent-filter> </receiver> <activity android:name="com.example.ipdialer.MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
记住:别忘记了权限,因为这也是要侵犯用户的隐私,所以要加上权限
还有一点:在2.3以下系统中,如果项目中只有 activity, 是可以的,但是在4.0系统上必须要有一个activity,否则广播无效,因为无activity,在桌面上没app图标,这会给一些想法不单纯的人开发对用户带来不好的app,因此google在4.0上修复了这个算bug吧
<span style="font: 24px/36px 楷体; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"></span>
0 0
- android IP拨号器
- Android ip拨号器
- android的IP拨号器
- 黑马Android:IP拨号器
- Android Broadcast IP拨号器
- android(33)(IP拨号器)
- Android广播接受者案例IP拨号器
- ip拨号器
- IP拨号器
- ip拨号器
- ip拨号器
- 案例:IP拨号器
- ip拨号器
- android 如何进行IP拨号
- Android初级教程IP拨号器初识广播接受者
- Android 6.0后ip拨号器权限问题
- 广播接受者:IP拨号器
- 广播接收者ip拨号器
- 百度云搜索
- 串联电阻
- Windows 7系统安装MySQL5.5.21图解
- C和C++格式化输入输出(复习)
- CentOS7 install ftp
- android IP拨号器
- UVa 12403 - Save Setu
- uva 11404 Palindromic Subsequence lcs 路径输出
- 消息队列简介及应用场景相关
- xv6阅读报告一(中间图片懒得贴了==)
- 没几把刷子,老板请你干嘛?句句震撼,不看遗憾终生
- 黑马程序员——交通灯管理系统的实现
- Eclipse快捷键
- 黑马程序员——高新技术(反射)