gpt4 book ai didi

android - 切换android Activity 时的致命信号6(SIGABRT)

转载 作者:行者123 更新时间:2023-11-30 02:16:57 25 4
gpt4 key购买 nike

我正在尝试从 PJSIP 调用的监听器中切换 Activity ,但出现此错误:致命信号 6 (SIGABRT),tid 8613 (Thread-23469) 中的代码 -6

我的监听代码:

    public void onIncomingCall(OnIncomingCallParam iprm){
Log.e("SIP_Account", "Receiving Call" );
SIP_Controler sip_controler = SIP_Controler.getInstance();
SIP_Call call = new SIP_Call(sip_controler.getSIPAccount(), sip_controler.getEndpoint());

if(sip_controler.hasActiveCall() ){
//If there is an active call, decline the incomming call and send busy signal
CallOpParam callOpParam = new CallOpParam();
callOpParam.setStatusCode(pjsip_status_code.PJSIP_SC_DECLINE);
try {
call.hangup(callOpParam);

} catch (Exception e) {
Log.e("SIP_Account", "Error while hanging up the incomming call " + e.toString());
}
}else{
Log.e("SIP_Account", "Try to change activity:" );
MiscFunctions.getCurrentForegroundActivity().changeActivity(VoIPViewCommands.RECEIVECALL, ActivityVoIPCall.class);
}
}

在 MiscFunctions 中,我得到了一个代码,允许我访问当前在前台的 Activity:

public class MiscFunctions {

static private TelephoneActivity currentForegroundActivity;


static public TelephoneActivity getCurrentForegroundActivity(){
return currentForegroundActivity;
}

static public void setCurrentForegroundActivity(TelephoneActivity ta){
currentForegroundActivity = ta;
}
...

TelephoneActivity 是 SherlockFragmentActivity 的扩展。

    /***************************************************************************************************
* All activities in this project should extend this activity. This one will make sure that you can
* always get the activity that is currently in the foreground of your app.
*
**************************************************************************************************/
public class TelephoneActivity extends SherlockFragmentActivity {

public void onResume(){
super.onResume();
MiscFunctions.setCurrentForegroundActivity(this);
}

public void changeActivity(VoIPViewCommands extra, Class activityClass){
Intent i = new Intent(getApplicationContext() , activityClass);
Log.e("TelephoneActivity", "Change the activity" );
i.putExtra("Command", extra);
getApplicationContext().startActivity(i); //this is the line that leads to a crash
//with 'Fatal signal 6 (SIGABRT), code -6 in tid 8613 (Thread-23469)' message.
}

}

谁能给我解释一下这里的问题是什么?

最佳答案

您收到的信号是“中止”信号,检查 this获取可能信号的列表。

我猜你的问题是 getApplicationContext().startActivity(i);这里。只需在此处编写 startActivity(i) 就可以了。

另请注意 this part关于 getApplicationContext 的 Android 文档:

Return the context of the single, global Application object of the current process. This generally should only be used if you need a Context whose lifecycle is separate from the current context, that is tied to the lifetime of the process rather than the current component.

关于android - 切换android Activity 时的致命信号6(SIGABRT),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29146820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com