开发者

Call Control Example Issue on Emulator

I am testing call control example given on: http://prasanta-paul.blogspot.com/2010/09/call-control-in-android.html on emultaor.

Code is as below:

package com.example.callblock;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.RemoteException;
import android.telephony.TelephonyManager;
import android.widget.Toast;

import com.android.internal.telephony.ITelephony;

public class CallBlock  extends BroadcastReceiver{

String[] blockedNumbers = {"5556"};
String incommingNumber;
Context context;
String incomingNumber;
ITelephony telephonyService;

public void onReceive(Context context, Intent intent) {


    //Log.v(TAG, "Incoming Call BroadCast received...");
    //      Log.v(TAG, "Intent: ["+ intent.getAction() +"]");

    Bundle b = intent.getExtras();
    incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
    Toast.makeText(context, "Phone no:"+incomingNumber, Toast.LENGTH_LONG).show();
    // Additional Step
    // Check whether this number matches with your defined Block List
    // If yes, Reject the Call
    if(incommingNumber.equals(blockedNumbers[0])){
        try {
            telephonyService.endCall();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}


   }

When i tried to run this example ie make call from one emulator(5556) to the second emulator(5554). It shows Phoneno:null.

I am unable to understand the reaso开发者_JAVA技巧n for this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜