How To Store Call Records In Sd Card?
I am trying to store incoming and outgoing calls record in my SD Card. but the issue is that i am not able to find that in my SD Card. Following is my Code Can any one help Device
Solution 1:
UPDATED ANSWER
Main2Activity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
ListenIncomingCalls.java
publicclassListenIncomingCallsextendsBroadcastReceiver {
@OverridepublicvoidonReceive(Context context, Intent intent) {
TelephonyManagertmgr= (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
CallListenerphoneListener=newCallListener();
tmgr.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
classCallListenerextendsPhoneStateListener {
@OverridepublicvoidonCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
System.out.println("Call state changed ");
if (state == TelephonyManager.CALL_STATE_RINGING) {
//phone ringing
System.out.println("This number is " + incomingNumber);
}
if(state == TelephonyManager.CALL_STATE_OFFHOOK)
{
System.out.println("Call is picked ");
//start CallRecordService Here to start recording
}
}
}
CallRecordService.java
publicclassCallRecordServiceextendsService {
MRecorder mRecorder;
longpassedSeconds=0;
NotificationCompat.Builder mBuilder;
NotificationManager mNotificationManager;
publicCallRecordService()
{
mRecorder = MRecorder.getInstance();
}
@Nullable@Overridepublic IBinder onBind(Intent intent) {
System.out.println("Service binded");
returnnull;
}
@OverridepublicvoidonCreate() {
super.onCreate();
System.out.println("Service called ");
mRecorder.startRecording();
IntentstopService=newIntent(this,StopPhoneReciever.class);
stopService.putExtra("stopRecording",true);
PendingIntentpendingIntent= PendingIntent.getService(getApplicationContext(),68,stopService,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder = (NotificationCompat.Builder) newNotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setOngoing(true)
.setContentIntent(pendingIntent)
.setContentTitle("Recording Call...")
.setContentText("Tap to stop recording.....");
Notificationnotification= mBuilder.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManagermNotificationManager=
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(68,notification);
}
@OverridepublicvoidonDestroy() {
mRecorder.stopRecording();
super.onDestroy();
}
}
Manifest.xml
<!--incoming calls receiver --><receiverandroid:name=".recorder.ListenIncomingCalls"><intent-filter><actionandroid:name="android.intent.action.PHONE_STATE"/></intent-filter></receiver><serviceandroid:name=".recorder.CallRecordService" />
Few useful links 1)https://www.codeproject.com/Articles/548416/Detecting-incoming-and-outgoing-phone-calls-on-And 2)http://androidexample.com/Incomming_Phone_Call_Broadcast_Receiver__-_Android_Example/index.php?view=article_discription&aid=61 Hope this helps:)
Post a Comment for "How To Store Call Records In Sd Card?"