Android Notification: Flash Message in Notification Area -


in android app, provide notification both when user begins uploading file , when file upload complete. when upload begins, message "uploading" appears in navigation bar. want message "uploading complete" flash in navigation bar when upload complete, message never appears in navigation bar. when expand notification drawer, though, correct message shown.

how content title flash in navigation bar?

notificationmanager mnotificationmanager =                         (notificationmanager) context.getsystemservice(context.notification_service);                 constant.currentlyuploading.decrementandget();                 constant.totaluploadedimages.incrementandget();                 if(constant.currentlyuploading.get()>0){                     string files_count;                     if(constant.currentlyuploading.get() ==1){                         files_count = "file";                     }else{                         files_count = "files";                     }                     builder uploadbuilder = new notificationcompat.builder(context)                     .setsmallicon(r.drawable.logo)                     .setcontenttitle("uploading")                     .setcontenttext(constant.currentlyuploading.get()+ " " + files_count +  " uploading");                     notification uploadnotif = uploadbuilder.build();                     mnotificationmanager.notify(constant.notification_uploading_id, uploadnotif);                 }else{                     // cancel uploading notification                     cancelnotification(this.context, constant.notification_uploading_id);                      string uploaded_count;                     if(constant.totaluploadedimages.get()>1){                         uploaded_count = "files";                     }else{                         uploaded_count = "file";                     }                     builder uploadedbuilder = new notificationcompat.builder(context)                     .setsmallicon(r.drawable.logo)                     .setcontenttitle("upload complete")                     .setcontenttext(constant.totaluploadedimages.get()+" " + uploaded_count + " uploaded")                     .setautocancel(true);                     notification uploadnotif = uploadedbuilder.build();                     mnotificationmanager.notify(constant.notification_uploaded_id, uploadnotif);                         constant.totaluploadedimages.getandset(0);                        }                 //removing 1 step's image upload counter                 uploadstep.dectotaluploading();                 if(stepadapter!=null){                     stepadapter.notifydatasetchanged();                 }                  //removing path list of uploading images                 uploadstep.removecurrentlyuploading(filepath);              } 

and cancel notification method:

public static void cancelnotification(context ctx, int notifyid){     string ns = context.notification_service;     notificationmanager nmgr = (notificationmanager) ctx.getsystemservice(ns);     nmgr.cancel(notifyid); } 

the answer ended being quite simple; had add following line updated notification:

.setticker("upload complete") 

here's complete code:

builder uploadedbuilder = new notificationcompat.builder(context)                 .setsmallicon(r.drawable.logo)                 .setcontenttitle("upload complete")                 .setticker("upload complete")                 .setcontenttext(constant.totaluploadedimages.get()+" " + uploaded_count + " uploaded")                 .setautocancel(true);                 notification uploadnotif = uploadedbuilder.build();                 mnotificationmanager.notify(constant.notification_uploading_id, uploadnotif);                    constant.totaluploadedimages.getandset(0);                    } 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -