我正在使用Android本机sip堆栈创建一个简单的sipcall。我希望在成功的SIP连接上显示一个特定的浮动操作按钮,并在失败的SIP连接上隐藏相同的浮动操作按钮。默认情况下,显示浮动操作按钮。有些显示部分不起作用,为什么找不到任何解决方案。正在android版本27上工作。以下是sip配置文件的实现部分。
/**
* Name: onRegistrationDone
* Description: Logs a status message indicating the
* SipProfile successfully registered.
*/
public void onRegistrationDone(String localProfileUri, long expiryTime) {
Log.e("$$", "Sip Profile <" + localProfileUri + "> successfully registered");
System.out.println( " login successful");
///我在成功注册时显示浮动操作按钮-无效
FloatingActionButton fab3 = (FloatingActionButton) findViewById(R.id.fab3);
fab3.show();
}
/**
* Name: onRegistrationFailed
* Description: Logs a status message indicating the
* SipProfile failed to register.
*/
public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
//隐藏浮动操作按钮-起作用
FloatingActionButton fab3 = (FloatingActionButton) findViewById(R.id.fab3);
fab3.hide();
Log.e("$$", "Sip Profile failed to register <" + localProfileUri + "> " +
" Error message: " + errorMessage);
System.out.println( " login unsuccessful. Error message:" + errorMessage);
}
});
} catch (ParseException e) {
Log.e("$$", "SipProfile was not built.");
e.printStackTrace();
} catch (SipException e) {
e.printStackTrace();
}
}
}
错误
android.util.AndroidRuntimeException: Animators may only be run on Looper threads at android.animation.ValueAnimator.start(ValueAnimator.java:969) at android.animation.ValueAnimator.start(ValueAnimator.java:1010) at android.animation.AnimatorSet.start(AnimatorSet.java:678) at android.animation.AnimatorSet.onChildAnimatorEnded(AnimatorSet.java:807) at android.animation.AnimatorSet.start(AnimatorSet.java:640) at com.google.android.material.floatingactionbutton.FloatingActionButtonImpl.hide(FloatingActionButtonImpl.java:423) at com.google.android.material.floatingactionbutton.FloatingActionButton.hide(FloatingActionButton.java:540) at com.google.android.material.floatingactionbutton.FloatingActionButton.hide(FloatingActionButton.java:536) at com.google.android.material.floatingactionbutton.FloatingActionButton.hide(FloatingActionButton.java:525) at com.serv24.eframe.MediaPresentationActivity$16.onRegistrationFailed(MediaPresentationActivity.java:1550) at android.net.sip.SipManager$ListenerRelay.onRegistrationFailed(SipManager.java:652) at android.net.sip.ISipSessionListener$Stub.onTransact(ISipSessionListener.java:180) at android.os.Binder.execTransact(Binder.java:573)
答案 0 :(得分:2)
请尝试此操作,可能会有所帮助:
runOnUiThread(new Runnable() {
@Override
public void run() {
fab3.show();
}
});