如何构建一个虚拟的来电提示,可以自定义联系人和号码,管理来电提示的类是哪个类?为什么我下面这段代码不行,望高人指点,在下新手希望得到点拨。
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class FakePhoneCall extends Activity
{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
int state1=TelephonyManager.CALL_STATE_RINGING;
CallYou callYou=new CallYou();
callYou.onCallStateChanged(state1, "123456677");
}
public class CallYou extends PhoneStateListener
{
public void onCallStateChanged(int state, String incomingNumber)
{
switch(state){
case TelephonyManager.CALL_STATE_OFFHOOK:
Toast.makeText(FakePhoneCall.this, "On Calling......", Toast.LENGTH_LONG).show();break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(FakePhoneCall.this, "On Calling......", Toast.LENGTH_LONG).show();break;
}
super.onCallStateChanged(state, incomingNumber);
}
}
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class FakePhoneCall extends Activity
{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
int state1=TelephonyManager.CALL_STATE_RINGING;
CallYou callYou=new CallYou();
callYou.onCallStateChanged(state1, "123456677");
}
public class CallYou extends PhoneStateListener
{
public void onCallStateChanged(int state, String incomingNumber)
{
switch(state){
case TelephonyManager.CALL_STATE_OFFHOOK:
Toast.makeText(FakePhoneCall.this, "On Calling......", Toast.LENGTH_LONG).show();break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(FakePhoneCall.this, "On Calling......", Toast.LENGTH_LONG).show();break;
}
super.onCallStateChanged(state, incomingNumber);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货