I want to save the outgoing call number and duration using broadcastreceiver service in android. I used the below code to achieve the functionality but it throws error.
public class OutgoingReceiver extends BroadcastReceiver {
public OutgoingReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
try
{
Bundle bundle = intent.getExtras();
number = bundle.getString(Intent.EXTRA_PHONE_NUMBER);
dbOutgoing = new DBOutgoing(ctx);
dbOutgoing.InsertOutGoingCallDB(number, "0", "0");
Toast.makeText(ctx,
"Outgoing: "+number,
Toast.LENGTH_LONG).show();
}
catch(FileNotFoundException e)
{
e.printStackTrace();
Toast.makeText(ctx, String.valueOf(e),Toast.LENGTH_LONG).show();
}
}
}
The above code is giving the outgoing call number, but I need the duration also after the call ends.