1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

android programming question

Discussion in 'Android Hacks and Help' started by mojo_droid, Aug 25, 2010.

  1. mojo_droid
    Offline

    mojo_droid Premium Member Premium Member Developer

    Joined:
    Jul 9, 2010
    Messages:
    367
    Likes Received:
    0
    Trophy Points:
    0
    i'm not sure if this is the right place to ask this, so please direct me to the correct place if this is wrong.

    I have an app that is constantly updated a notification in the status bar (changing the icon and updated text in the expanded view). The problem I am having is that when it updates the notification it will close the window I am in for certain actions. For example, if I am looking through my apps when it updates it will close that and take me to the home screen, if I am searching for something in the market it will close the search history, etc. Is there a way to have it update the icon and text in the background and not effect any currently running activity?

    here is my notification code:

    Code:
    public void displayNotification(String msg)
      {
        RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
    
        settings = context.getSharedPreferences(PREFS_NAME, 0);
        statColor = settings.getInt("txtColor", Color.BLACK);
         contentView.setTextColor(R.id.text, statColor);
         contentView.setTextColor(R.id.text2, statColor);
         contentView.setTextColor(R.id.text3, statColor);
    
          contentView.setTextViewText(R.id.text, "some text");
          contentView.setTextViewText(R.id.text2, "some more text");
          contentView.setTextViewText(R.id.text3, "some more text");
    
          contentView.setImageViewResource(R.id.image, icon[iconIndex]);
          Notification notification = new Notification(icon[iconIndex], msg, System.currentTimeMillis());
          notification.contentView = contentView;
          Intent notificationIntent = new Intent(this, AppService.class);
          PendingIntent contentIntent = PendingIntent.getActivity(this, 1, notificationIntent, 0);
          notification.contentIntent = contentIntent;
    
          manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
          notification.flags |= Notification.FLAG_NO_CLEAR;
          notification.flags |= Notification.FLAG_ONGOING_EVENT;
          manager.notify(NOTIFICATION_ID, notification);
    
    
      }
  2. mojo_droid
    Offline

    mojo_droid Premium Member Premium Member Developer

    Joined:
    Jul 9, 2010
    Messages:
    367
    Likes Received:
    0
    Trophy Points:
    0
    you can delete this thread, i figured out the issue
Search tags for this page

android removecontentview