无振铃事件的来电 [英] No ringing event on incoming calls
问题描述
我不知道哪里出了问题。
监听器不赶 onRinging
事件(这样我就可以决定,我会接受或拒绝来电)。
清单中是这样的:
I don't know where is a problem.
Listener doesn't catch onRinging
event (so I can decide will I accept or reject incoming calls).
in manifest is this:
<uses-permission android:name="android.permission.USE_SIP" />
在主要活动的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
(在我结束通话),但我不接受她 onRinging
事件。
这可能是一个问题吗?
日Thnx
I recieve CallEnd
event and onChanged
(after I end call) but I dont recieve onRinging
event.
what could be a problem?
Thnx
编辑: 我改变了这一切。 我提出了新的意图过滤器来接收这样的(粗体):
EDIT : I changed it all. I put new intent filter to receiver like this (bold):
<receiver android:name=".IncomingCallReceiver" android:label="Call Receiver">
**<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>**
</receiver>
和我改变BroadcastReceiver的继承像这样(大胆的)类:
and I changed BroadcastReceiver inherit class like this (bold one):
@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);**
...
现在我只得到IDLE状态,但仍然没有铃声。
Now I get only IDLE state but still there is no ringing.
推荐答案
有一个在SipAudioCall类的源$ C $ C错误。
There is an error in the source code of SipAudioCall class.
要解决此问题:
incomingCall = wtActivity.manager.takeAudioCall(intent, null);
incomingCall.setListener(listener, true);
这篇关于无振铃事件的来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!