android来电事件,android – 来电时没有响铃事件
我不知道問題出在哪里.
監(jiān)聽器沒有捕獲到鈴聲事件(所以我可以決定接受還是拒絕來電).
在清單中是這樣的:
在主要活動onCreate是這樣的:
IntentFilter filter = new IntentFilter();
filter.addAction("android.SipDemo.INCOMING_CALL");
callReceiver = new IncomingCallReceiver();
this.registerReceiver(callReceiver, filter);
...
SipManager manager = SipManager.newInstance(this);
Intent i = new Intent();
i.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
manager.open(me, pi, null);
在BroadcastReceiver類中是這樣的:
public void onReceive(Context context, Intent intent) {
SipAudioCall incomingCall = null;
try {
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
...
@Override
public void onCallEnded(SipAudioCall call) {
// TODO Auto-generated method stub
super.onCallEnded(call);
}
@Override
public void onRinging(SipAudioCall call, SipProfile caller) {
try {
call.answerCall(30);
call.startAudio();
call.setSpeakerMode(true);
if(call.isMuted()) {
call.toggleMute();
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
WalkieTalkieActivity wtActivity = (WalkieTalkieActivity) context;
incomingCall = wtActivity.manager.takeAudioCall(intent, listener);
wtActivity.call = incomingCall;
...
我收到CallEnd事件和onChanged(在我結(jié)束通話后),但我沒有收到關(guān)于鈴聲的事件.
什么可能是一個(gè)問題?
日Thnx
編輯:
我改變了一切.
我把新的意圖過濾器放到這樣的接收器(粗體):
**
**
我更改了BroadcastReceiver繼承類(粗體):
@Override
public void onReceive(Context context, Intent intent) {
try {
**PhoneStateListener phoneListener=new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
// TODO Auto-generated method stub
Log.d("DEBUG", "Phone listener....");
String stateString = "N/A";
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
stateString = "Idle";
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
stateString = "Off Hook";
break;
case TelephonyManager.CALL_STATE_RINGING:
stateString = "Ringing";
break;
}
}
};**
WalkieTalkieActivity wtActivity = (WalkieTalkieActivity) context;
SipSession ses=wtActivity.manager.getSessionFor(intent);
**TelephonyManager telephony = (TelephonyManager) Context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);**
...
現(xiàn)在我只得到IDLE狀態(tài),但仍然沒有響.
總結(jié)
以上是生活随笔為你收集整理的android来电事件,android – 来电时没有响铃事件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 3位水仙花数计算pythonoj_Pyt
- 下一篇: python summary write