Note that there are some explanatory texts on larger screens.

plurals
  1. POending call in android using telephonyserivce.endcall()
    primarykey
    data
    text
    <p>I am working on app where i want to end outgoing call. this is the main class</p> <pre><code>import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; public class phonecalls extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); call(); } private void call() { try { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:123456789")); startActivity(callIntent); } catch (ActivityNotFoundException activityException) { Log.e("dialing-example", "Call failed", activityException); } } } </code></pre> <p>and outgoingclass is this</p> <pre><code>import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.TelephonyManager; import android.util.Log; import android.widget.Toast; import com.android.internal.telephony.ITelephony; import java.lang.reflect.Method; public class OutgoingCallReceiver extends BroadcastReceiver { private final String TAG = "CallControl"; Context context; String incomingNumber; ITelephony telephonyService; @Override public void onReceive(Context context, Intent intent) { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); try { // Java reflection to gain access to TelephonyManager's // ITelephony getter 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; Toast.makeText(context, info, Toast.LENGTH_LONG).show(); Log.v(TAG, "Get getTeleService..."); Class c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); telephonyService=(ITelephony) m.invoke(tm); telephonyService.endCall(); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "FATAL ERROR: could not connect to telephony subsystem"); Log.e(TAG, "Exception object: " + e); } } } </code></pre> <p>But the call is not ended even though i am able to print no. when outgoing call starts which show broadcasting receiver is working right .</p> <p>Any suggestion</p>
    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.
 

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