codingdir logo sitemap sitemap |

How to add my app's icon into the status bar when my app is running?

By : , Category : android

You have to call the method build() after you have finished describing your notification. Check out the Android reference for an example.

Basically, you have to change your code to the following:

Context context = getApplicationContext();
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)

Intent intent = new Intent( context, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, mID , intent, 0);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

Notification notif =;
mNotificationManager.notify(mID, notif);

Note: this code will only allow to show your icon in the notification bar. If you want it to persist there, you will have to use FLAG_ONGOING_EVENT

ReLated :

You do not need to stop using dequeueReusableCellWithIdentifier. The issue is that the cells are being reused, but if it's just the image for the button that is incorrect, add in a check to see which image needs to be displayed.

func configureCell(cell: MyCustomTableViewCell, atIndexPath indexPath: NSIndexPath) {

    let aObject = self.fetchedResultsController.objectAtIndexPath(indexPath) as CustomObject

    cell.customLabel.text =
    cell.detailLabel.text = aObject.anotherProperty
    if aObject.isActive { // set button to active }
    else { // set button to inactive }

    cell.objectToMarkAsInactive = aObject

I think it might not be a bug but a feature of iOS 7. Try adding the following method to your app's root view controller:

- (BOOL)prefersStatusBarHidden
    return YES;

Have a look into this question: Status bar won't disappear

For the example you provided they are calling:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)

Note that they are NOT calling .setLargeIcon

By nature, notifications will not persist through a device reboot. You will manually need to determine when the device has been restarted and issue the notification again.

Trying to start a service on boot on Android


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © All Rights Reserved .