如何设置在Android状态栏通知文本 [英] How to set text on status bar notification in Android
本文介绍了如何设置在Android状态栏通知文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道如何设置状态栏notifaction Android中请给一些想法
i dont know how to set status bar notifaction in android please give some idea
推荐答案
您参考@spectrum:的 http://developer.android.com/guide/topics/ui/notifiers/notifications.html
@spectrum you will refer:http://developer.android.com/guide/topics/ui/notifiers/notifications.html
通知
Notification notification = new Notification(
android.R.drawable.stat_sys_warning, //Icon to use
"Hello World!", //Text
System.currentTimeMillis() //When to display - i.e. now
);
创建的PendingIntent,当用户点击通知做点什么
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
//Add to the Notification
notification.setLatestEventInfo(
getApplicationContext(),
"Stack Overflow", //Title of detail view
"This will launch Stack Overflow", //Text on detail view
pi
);
//Display the Notification
NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(ID_HELLO_WORLD, notification); //ID_HELLO_WORLD is a int ID
这篇关于如何设置在Android状态栏通知文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文