切换 android 活动时出现致命信号 6 (SIGABRT)

Fatal signal 6 (SIGABRT) while switching android activities

我正在尝试从 PJSIP 调用的侦听器中切换活动, 但出现此错误:Fatal signal 6 (SIGABRT), code -6 in tid 8613 (Thread-23469).

我的监听代码:

    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.
        }

    } 

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

您收到的信号是 'abort' 信号,检查 this 以获得可能的信号列表。

我猜你的问题出在 getApplicationContext().startActivity(i);这里。在这里写startActivity(i)就可以了

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

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.