0

in my application images are uploaded on server in IntentService after all images are uploaded. intent service sends broadcast, and onReceive method receives response and displays appropriate alert message. But if my app is in pause or other application are activated and after my application opens, alert message is not displayed. If my app is in foreground it will display alert message. How do I solve this problem, should I used boolean shared preferences in IntentService when download complete check boolean value onresume method and alert display when user open my app?

/*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();
        }
    }
};
/**/
4

0 に答える 0