How to make text appear in an android notification? -


i trying create notification on android in order notify user if happening. here example code (called mainactivity)

notificationcompat.builder mbuilder =             new notificationcompat.builder(this)             .setsmallicon(r.drawable.stoxx_icon)             .setcontenttitle("my notification")             .setcontenttext("hello world!"); intent resultintent = new intent(this, mainactivity.class);  taskstackbuilder stackbuilder = taskstackbuilder.create(this); stackbuilder.addparentstack(mainactivity.class); stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent =             stackbuilder.getpendingintent(                 0,                 pendingintent.flag_update_current             ); mbuilder.setcontentintent(resultpendingintent); notificationmanager mnotificationmanager =         (notificationmanager) getsystemservice(context.notification_service); int mid = 1001; mnotificationmanager.notify(mid, mbuilder.build()); 

the notification shown on screen (no lock screen, normal un-locked screen) , when swipe notification bar down (like figure 2 in documentation) can see well, text follows:

myapplication contents hidden 

i expecting see following content:

my notification hello world! 

i looked in documentation did not find can use solve problem(i looked @ setvisibility, seems relevant lock-screen not have here). maybe overlooked it, maybe nothing have notification. idea how solve problem?

setting setvisibility(notificationcompat.visibility_public) makes text readable on lock screen (not want) , setvisibility(notificationcompat.visibility_secret) not show notification on lock screen @ all.

what want:

  • lock-screen: notification shown 'contents hidden'
  • unlocked screen: notification shown content given in code.

what visibility_private:

  • lock-screen: notification shown 'contents hidden'
  • unlocked screen: notification shown 'contents hidden'

what visibility_public:

  • lock-screen: notification shown with content given in code.
  • unlocked screen: notification shown with content given in code.

what visibility_secret:

  • lock-screen: notification not shown @ all.
  • unlocked screen: unknown


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -