Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6740413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:36:11+00:00 2026-05-26T11:36:11+00:00

I have a interesting problem. I have a Service implementation in my android App,

  • 0

I have a interesting problem. I have a Service implementation in my android App, which syncs with the Server and if a new order comes, it displays a notification and a dialog with SHO/DISMISS buttons. Because I need to display the dialog regardless of the activity currently running, I have implemented it as another activity a start this one from the service, when new order appears.

The activity doesn’t set any view, just creates an AlertDialog. The SHOW button starts the OrdersListActivity, and the DISMISS button just closes the dialog. Everything works fine, but only on the first time. If I dismiss the dialog, and another order comes, it is displayed again. However, if I click on the SHOW button, it displays the OrdersList but when another order comes later, the dialog is not displayed. Although, according to the logcat, the activity is started. I’ve been messing with this for some hours already, could you please help me? Thanks.

Here is the method from my Service class (makes a notification, sends a broadcast and start the Dialog activity):

public void notifyNewOrder() {

    Context context = getApplicationContext();

    Intent notificationIntent = new Intent(this, OrdersService.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);

    newOrderNotification.setLatestEventInfo(this, getString(R.string.notification_text), getString(R.string.notification_text), contentIntent);
    notificationManager.notify(NOTIFICATION_ID, newOrderNotification);


    Intent intent = new Intent(NEW_ORDER_RECEIVED);
    sendBroadcast(intent);

    Intent dialog = new Intent(context, NotificationDialog.class);
    dialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(dialog);

}

Here is the code of the NotificationDialog activity class:

public class NotificationDialog extends Activity {

private static final int DIALOG_NEW_ORDER = 0;
private static final String LOG_TAG = "NotificationDialog"; 

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    Log.d(LOG_TAG, "onCreate - creating activity...");

}

@Override
public void onResume() {

    super.onResume();
    Log.d(LOG_TAG, "onResume - starting the dialog...");
    showDialog(DIALOG_NEW_ORDER);

}



@Override
protected Dialog onCreateDialog(int id) {

    Dialog dialog;

    switch(id) {
        case DIALOG_NEW_ORDER:

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage(R.string.notification_dialog_new_order)
                   .setCancelable(false)
                   .setPositiveButton(R.string.notification_dialog_show, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                            /*
                            * Cancel the notification
                            */
                            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                            notificationManager.cancel(OrdersService.NOTIFICATION_ID);                              

                            /*
                             * Go to the list
                             */
                            Intent listIntent = new Intent(getApplicationContext(), OrdersListActivity.class);
                            startActivity(listIntent);

                            dialog.dismiss();
                            finish();

                        }

                   })
                   .setNegativeButton(R.string.notification_dialog_dismiss, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                            /*
                             * Cancel the notification
                             */
                            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                            notificationManager.cancel(OrdersService.NOTIFICATION_ID);
                            dialog.dismiss();
                            finish();
                        }
                   });

            dialog = builder.create();

            break;        
        default:
            dialog = null;
    }

    return dialog;
}

}

I’ve added some logs in the onCreate and onResume methods of the NotificationDialog activity and found out following:

  1. The first time the NotificationDialog activity is started, those debug messages are printed out
  2. The second time, and all the other times, they won’t show up, although logcat says: 10-28 10:00:38.074: INFO/ActivityManager(63): Starting: Intent { flg=0x10000000 cmp=pl.mymeal.orders/.services.NotificationDialog } from pid 1001
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:36:11+00:00Added an answer on May 26, 2026 at 11:36 am

    Change the flag to FLAG_ACTIVITY_CLEAR_TOP. Just mind that there is no affection on the new data from the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I came across an interesting problem today. We have a WCF web service
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I have an interesting problem being reported to me from an android application I
We have a web service which provides search over hotels. There is a problem
I have a very interesting problem. I use this technologies in WPF app: Caliburn.Micro
I have an interesting problem. My app runs fine on the iphone 4.2 simulator,
I have an interesting problem and would appreciate your thoughts for the best solution.
I have one interesting problem. I must parse mail body (regular expression), get some
I have some interesting problem for an hour.. In my flex project, all width
I have an interesting problem. The basis of the problem is that my last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.