Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends

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.

Please help me resolve this.

Java
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 want the duration also after the call ends. Please share the full code if possible.

Thanks in advance
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900