Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hey Finally i got solution for that.. like this you can also get that.</p> <p>You have to use <code>ITelephony.aidl</code> file Like this:</p> <pre><code>package com.android.internal.telephony; import android.os.Bundle; interface ITelephony { boolean endCall(); void dial(String number); void answerRingingCall(); void abortCall(); } </code></pre> <p>And In <code>OutgoingCallReceiver</code></p> <pre><code>public class OutgoingCallReceiver extends BroadcastReceiver { Context context = null; private static final String TAG = "Phone call"; private ITelephony telephonyService; @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if (null == bundle) return; String phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); Log.i("OutgoingCallReceiver", phonenumber); Log.i("OutgoingCallReceiver", bundle.toString()); String info = "Detect Calls sample application\nOutgoing number: "+ phonenumber; /* System.out.println("value id:"+info); */ Toast.makeText(context, info, Toast.LENGTH_LONG).show(); TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); try { Class c = Class.forName(telephony.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); /* * com.android.internal.telephony.ITelephony telephonyService = * (ITelephony) m.invoke(tm); */ telephonyService = (ITelephony) m.invoke(telephony); telephonyService.answerRingingCall(); telephonyService.endCall(); telephonyService.dial(null); telephonyService.abortCall(); } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>And if you want to get <code>IncomingCallReceiver</code> then Like this you can:</p> <pre><code>public class IncomingCallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if(null == bundle) return; Log.i("IncomingCallReceiver",bundle.toString()); String state = bundle.getString(TelephonyManager.EXTRA_STATE); Log.i("IncomingCallReceiver","State: "+ state); if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) { String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); Log.i("IncomingCallReceiver","Incomng Number: " + phonenumber); System.out.println("Coming in Incoming Number"+phonenumber); String info = "Detect Calls sample application\nIncoming number: " + phonenumber; Toast.makeText(context, info, Toast.LENGTH_LONG).show(); } } } </code></pre> <p>And ya Guys don't forget to add Permission in <code>AndroidManifest</code> file : </p> <pre><code> &lt;receiver android:name="com.varma.samples.detectcalls.receivers.OutgoingCallReceiver" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.NEW_OUTGOING_CALL" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;receiver android:name="com.varma.samples.detectcalls.receivers.IncomingCallReceiver" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.PHONE_STATE" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt; &lt;uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /&gt; &lt;uses-permission android:name="android.permission.CALL_PHONE" /&gt; &lt;uses-permission android:name="android.permission.CALL_PRIVILEGED" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload