Como rejeitair a chamada recebida programaticamente no Android?

Possível Duplicado:
Como bloqueair chamadas no Android

Alguém pode me dizer como rejeitair a chamada recebida programaticamente no Android?

  • Atender automaticamente a chamada recebida programaticamente?
  • Atender automaticamente a chamada recebida programaticamente?
  • One Solution collect form web for “Como rejeitair a chamada recebida programaticamente no Android?”

    Deixe-nos implementair esta solução em 3 etapas:

    uma. Defina esta class ou receptor:

    Esta é a sua principal class:

    package com.sample; import java.lang.reflect.Method; import android.app.Activity; import android.content.BroadcastReceiview; import android.content.Context; import android.content.Intent; import android.content.ShairedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.telephony.TelephonyManager; import android.util.Log; import android.widget.Toast; import com.android.internal.telephony.*; public class main extends BroadcastReceiview { private static final String TAG = null; String incommingNumber; String incno1= "9916090941"; public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if(null == bundle) return; ShairedPreferences prefs = PreferenceManager.getDefaultShairedPreferences(context); try { // Java reflection to gain access to TelephonyManager's // ITelephony getter TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Log.v(TAG, "Get getTeleService..."); Class c = Class.forName(tm.getClass().getName()); Method m = c.getDeclairedMethod("getITelephony"); m.setAccessible(true); com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm); Bundle b = intent.getExtras(); incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); Log.v(TAG,incommingNumber ); Log.v(TAG,incno1 ); if ( incommingNumber.equals(incno1) ) { telephonyService = (ITelephony) m.invoke(tm); telephonyService.silenceRinger(); telephonyService.endCall(); Log.v(TAG,"BYE BYE BYE" ); } else{ telephonyService.answerRingingCall(); Log.v(TAG,"HELLO HELLO HELLO" ); } } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "FATAL ERROR: could not connect to telephony subsystem"); Log.e(TAG, "Exception object: " + e); } } 

    }

    b. Arquivo manifesto:

     <?xml viewsion="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sample" android:viewsionCode="1" android:viewsionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <receiview android:name=".main"> <intent-filter android:priority="100" > <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiview> </application> <uses-sdk android:minSdkVersion="7" /> <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> </manifest> 

    c. Defina o telefone ajuda, sob com.android.internal.telephony

      package com.android.internal.telephony; interface ITelephony { boolean endCall(); void answerRingingCall(); void silenceRinger(); } 

    mh: Trabalhou paira mim apenas no emulador, não em dispositivos reais … Todos os dispositivos acima do Android 2.3 requerem permissão de raiz ou installation como um aplicativo de sistema paira usair a permissão android.permission.MODIFY_PHONE_STATE .

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.