我正在开发一个应用程序,我必须覆盖INCOMING CALL SCREEN.
当设备收到呼叫时,我必须显示我的应用程序的弹出窗口.我已经对这项任务进行了详细的研究. CALL POPOUT是一个使用相同功能的应用程序,但我没有得到源代码.
目前我没有几个模块可以通过它来获得INCOMING CALL的动作.
public class MyPhonestateListner extends PhoneStateListener {
Context context;
List blockedNumberList = new ArrayList();
BlockDataSource datasourceobj;
public MyPhonestateListner(Context context) {
super();
this.context = context;
}
@Override
public void onCallStateChanged(int state,String callingNumber) {
super.onCallStateChanged(state,callingNumber);
callingNumber = callingNumber.replace(" ","");
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
// handle out going call
// if(blockedNumberList.contains(callingNumber))
endCallIfBlocked(callingNumber);
break;
case TelephonyManager.CALL_STATE_RINGING:
// handle in coming call
new Handler().postDelayed(new Runnable() {
public void run() {
Intent intentPhoneCall = new Intent("android.intent.action.CALL");
intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentPhoneCall);
}
},10);
// if(blockedNumberList.contains(callingNumber))
//endCallIfBlocked(callingNumber);
// ActivityManagerNative.getDefault().moveTaskToBack(i);
//android.app.ActivityManager.RunningTaskInfo runningtaskinfo = TaskUtil.getPresentTaskInfo(this);
break;
default:
break;
}
}
}
MY reciever
public class BlockReciever extends BroadcastReceiver {
@Override
public void onReceive(Context context,Intent intent) {
System.out.println("I am reciever");
TelephonyManager telephony = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
MyPhonestateListner listener = new MyPhonestateListner(context);
telephony.listen(listener,PhoneStateListener.LISTEN_CALL_STATE);
}
}
在上面的代码的帮助下,我得到了我的应用程序的MAP屏幕在呼叫屏幕的顶部,但只是少量微秒钟,然后进入呼叫屏幕在顶部.
当设备接到任何电话并且需要显示我的应用程序的屏幕时,我必须隐藏呼叫屏幕.
请建议.