采用服务窃听电话
来源:互联网 发布:flash网页制作软件 编辑:程序博客网 时间:2024/05/01 11:38
manifest
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.RECORD_AUDIO"/>
<service android:name=".PhoneStatusService" > </service>PhoneStatusService
package org.gentry.callstatuslistener;import android.app.Service;import android.content.Intent;import android.media.MediaRecorder;import android.os.IBinder;import android.telephony.PhoneStateListener;import android.telephony.TelephonyManager;public class PhoneStatusService extends Service {/** * 长期在后台运行的组件,如果用户不手动的关闭,是不会停止的 */@Overridepublic IBinder onBind(Intent intent) {// TODO Auto-generated method stubreturn null;}@Overridepublic void onCreate() {super.onCreate();System.out.println("服务被创建了");// 监视用户电话状态的变化TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); // 电话管理器,电话管理的服务tm.listen(new MyPhoneStatusLinstener(),PhoneStateListener.LISTEN_CALL_STATE); // 监听手机的通话状态的变化}private class MyPhoneStatusLinstener extends PhoneStateListener {private MediaRecorder recorder;@Overridepublic void onCallStateChanged(int state, String incomingNumber) {try {switch (state) {case TelephonyManager.CALL_STATE_IDLE: // 空闲状态,手机没有通话,没有响铃if (recorder != null) {recorder.stop();recorder.reset(); // You can reuse the object by going// back// to// setAudioSource() steprecorder.release(); // Now the object cannot be reusedrecorder = null;}break;case TelephonyManager.CALL_STATE_RINGING: // 响铃状态System.out.println("发现来电号码:" + incomingNumber);// 1. 创建出来一个录音机recorder = new MediaRecorder();recorder.setAudioSource(MediaRecorder.AudioSource.MIC); // 设置录制的音频源,从话筒里面获取声音recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); // 文件输出格式recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // 声音编码格式recorder.setOutputFile("/sdcard/"+ System.currentTimeMillis() + ".3gp"); // 录音保存的路径recorder.prepare();break;case TelephonyManager.CALL_STATE_OFFHOOK: // 通话状态if (recorder != null) {recorder.start(); // Recording is now started}break;}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}super.onCallStateChanged(state, incomingNumber);}}@Overridepublic void onDestroy() {super.onDestroy();System.out.println("服务被销毁了");}}MainActivity
package org.gentry.callstatuslistener;import android.app.Activity;import android.content.Intent;import android.os.Bundle;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Intent intent = new Intent(this, PhoneStatusService.class);startService(intent);}}
0 0
- 采用服务窃听电话
- android 使用服务来窃听电话,并且通过语音录制
- android 使用服务来窃听电话,并且通过语音录制
- 安卓开发-开机时启动电话窃听service服务
- 电话窃听和拦截应用
- 电话窃听和拦截应用
- 电话窃听和拦截应用
- android-电话窃听功能
- 电话窃听和拦截应用
- Oracle 窃听服务
- Project——采用服务实现电话窃听器
- [Android] Android之Service案例-电话窃听
- Android之Service案例-电话窃听
- Service及用Service实现电话窃听
- 窃听
- 采用aidl挂断电话
- [Android开发]Android之Service案例-电话窃听
- 我的Android进阶之旅------>Android电话窃听实例
- 强制删除正在连接的Oracle用户,以删除SDE用户为例
- 9.更多组件
- -bash: crontab: command not found
- 安卓从网络获取图片
- linux下计算程序运行时间
- 采用服务窃听电话
- 如何找回Oracle中system,sys用户的密码
- c# 截屏代码
- Iterator和ListIterator
- 游泳学习,强身健体,链接
- Tachyon 分布式内存文件系统
- bmp转jpg(使用libjpeg)
- 错排
- zoj 1240 IBM Minus One