Java Android在启动拨入程序后强制关闭
大家好,我正在创建一个android程序,在这个程序中,我可以通过数组中的数字列表拨打电话。根据按钮的不同,单击该按钮将选择适当的阵列。无论我的程序强制关闭,我都可以拨打电话。这是不好的,因为我需要一个对话框弹出后(这部分我已经完成了,但没有办法告诉)我增量内的方法为对话框,我可以张贴它,如果你喜欢它。以下是我所拥有的:Java Android在启动拨入程序后强制关闭,java,android,Java,Android,大家好,我正在创建一个android程序,在这个程序中,我可以通过数组中的数字列表拨打电话。根据按钮的不同,单击该按钮将选择适当的阵列。无论我的程序强制关闭,我都可以拨打电话。这是不好的,因为我需要一个对话框弹出后(这部分我已经完成了,但没有办法告诉)我增量内的方法为对话框,我可以张贴它,如果你喜欢它。以下是我所拥有的: public class ServiceReceiver extends BroadcastReceiver { public void onReceive(Conte
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();
}
我接受了你提供的代码,并替换了我之前在清单中的代码。如果你觉得有帮助的话,我可以再发一次 我打赌你的清单上有这个
但它实际上并不存在。你可能拼错了什么
问题是您有活动
对于评论中的其他问题,您需要至少包括强制关闭时附带的堆栈转储。您还应该包括它引用的相关代码。至少没有这样的信息级别,而不是在StAccess上发布,您可能会考虑在SigalBo球上发布。我正试图使用ARCA应用程序将我的崩溃变成我的谷歌文档的电子表格。有什么方法对你更好吗?嘿,雷诺,这是我的接收器:是的,是的。我真的很感谢你的帮助,我真的迷路了。有什么我可以给你看的吗?编辑你的问题并输入你的清单和广播接收代码。另外,如果清单占用您太多时间,您可以直接执行此操作IntentFilter filter=newintentfilter()代码>filter.setAction(“android.intent.action.PHONE_STATE”);寄存器接收器(接收器、过滤器)代码>即注册你的接收器DynamicCallYok我将添加清单,你不知道如何添加广播接收器代码,是吗?雷诺没有这样做,我编辑了我的问题,包括你添加的部分并添加了我的清单…再次感谢你的帮助!