大家好,我正在創建一個Android程序,我要從數組中的數字列表撥打電話。根據點擊按鈕,它將選擇適當的數組。我可以撥打電話,但我的程序部隊關閉。這很糟糕,因爲我需要一個對話框以後彈出(我已經完成了那部分內容,但沒辦法告訴),我在對話框的方法內部增加了內容,如果你們需要,我可以發佈它。這是我有:Android強制關閉後啓動程序撥號
public class ServiceReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
MyPhoneStateListener phoneListener=new MyPhoneStateListener();
TelephonyManager telephony = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}
}
public class MyPhoneStateListener extends PhoneStateListener {
public void onCallStateChanged(int state,String incomingNumber){
boolean mCall=false;
switch(state){
case TelephonyManager.CALL_STATE_IDLE:
Log.d("DEBUG", "IDLE");
if(mCall)
{
mCall=false; //Reverting the flag, indicating you are aware that there was call
// Here do the rest of your operation you want
showAlert();
}
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("DEBUG", "OFFHOOK");
mCall=true;
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d("DEBUG", "RINGING");
mCall=true;
break;
}
}
}
public void showAlert(){
new AlertDialog.Builder(this)
.setTitle("Was This Call Sucessful?")
.setMessage("Did you get through and is help on the way?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d("AlertDialog", "Positive");
startActivity(new Intent("first.Package.HaitiDisasterPhoneAppActivity"));
} })
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.d("AlertDialog","Negative");
i++;
sequence();
} })
.show();
}
我把你給的代碼,並取代了我在清單之前的清單。如果您認爲它會有所幫助,我可以再次發佈它!
您需要包括在最低限度,伴隨着你的部隊密切堆棧轉儲。您還應該包含它所指的相關代碼。如果沒有這個級別的信息,你可能會考慮發佈在crystalball上,而不是發佈在stackoverflow上。 – mah
我正在嘗試使用ARCA應用程序將我的崩潰記錄到我的Google文檔的電子表格中,有沒有一種方法可以讓您更好? – smithseanp16