在我的应用程序中IntentService
,所有图像上传后,图像都会上传到服务器上。意图服务发送广播,onReceive
方法接收响应并显示适当的警报消息。但是,如果我的应用程序处于暂停状态或其他应用程序被激活,并且在我的应用程序打开后,不会显示警报消息。如果我的应用程序在前台,它将显示警报消息。我该如何解决这个问题,我应该在IntentServiceboolean
中使用共享首选项下载完成检查布尔值 onresume 方法并在用户打开我的应用程序时显示警报?
/*getting response from service*/
BroadcastReceiver br=new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("recived", "service broadcast");
String response=intent.getStringExtra("response");
if(response.equals("null"))
{
AlertDialog alert = new AlertDialog.Builder(
Note_Signature_activity.this).create();
alert.setTitle("Connection Time Out");
alert.setCancelable(false);
alert.setMessage("Connection Time Out Please Check Your Internet Connection");
alert.setIcon(android.R.drawable.ic_dialog_info);
alert.setButton(AlertDialog.BUTTON_NEGATIVE, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
final_submit_button.setClickable(true);
pb.dismiss();
}
});
alert.show();
}
else
{
final_submit_button.setClickable(true);
AlertDialog alert = new AlertDialog.Builder(
Note_Signature_activity.this).create();
alert.setTitle("Success");
alert.setCancelable(false);
alert.setMessage("Congratulations Successfully Submitted!");
alert.setIcon(android.R.drawable.ic_dialog_info);
alert.setButton(AlertDialog.BUTTON_NEGATIVE, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
final_submit_button.setClickable(false);
pb.dismiss();
clear_main_history();
Intent select_trip_section=new Intent(Note_Signature_activity.this, SelectTripActivity.class);
select_trip_section.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(select_trip_section);
}
});
alert.show();
}
}
};
/**/