NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// The details of our fake message
CharSequence from = "Joe";
CharSequence message = "kthx. meet u for dinner. cul8r";
// The PendingIntent to launch our activity if the user selects this notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, IncomingMessageView.class), 0);
// The ticker text, this uses a formatted string so our message could be localized
String tickerText = getString(R.string.imcoming_message_ticker_text, message);
// construct the Notification object.
Notification notif = new Notification(R.drawable.stat_sample, tickerText,
System.currentTimeMillis());
// Set the info for the views that show in the notification panel.
notif.setLatestEventInfo(this, from, message, contentIntent);
1: // after a 100ms delay, vibrate for 250ms, pause for 100 ms and
// then vibrate for 500ms.
notif.vibrate = new long[] { 100, 250, 100, 500}; //设置震动模式
2: notification.defaults = 提示模式 eg
setDefault(Notification.DEFAULT_SOUND); //默认声音
setDefault(Notification.DEFAULT_VIBRATE);//默认震动
setDefault(Notification.DEFAULT_ALL);//声音+震动
3:/ /自己设定消息提示View
// our custom view
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.status_bar_balloon);
contentView.setTextViewText(R.id.text, text);
contentView.setImageViewResource(R.id.icon, moodId);
notif.contentView = contentView;
// Note that we use R.layout.incoming_message_panel as the ID for
// the notification. It could be any integer you want, but we use
// the convention of using a resource id for a string related to
// the notification. It will always be a unique number within your
// application.
nm.notify(R.string.imcoming_message_ticker_text, notif);
分享到:
相关推荐
android ApiDemo android ApiDemo
android apidemo.apk
android sdk中拿出来的 android api demo,sdk\samples\android-17,给需要的人
关于apidemo的例子,里面的例子非常的不错啊
Google官方API(Android ApiDemo) 打包下载,初学者学习的捷径
Android官方apidemo,android studio直接导入,运行安装即可
android apidemo android apidemo android apidemo
谷歌官方Android ApiDemo,可直接导入Android Studio,全部配置好,导入即可跑通安装!
android中文apidemo详解事例,适合新手阅读快速上手。
android APIdemo 深入分析
腾讯微博APIDemo aip sdk
android 示例源码 apidemo 内容很全的,直接导入即可使用学习
最新6.0,最新APIDEMO
在SpringBoot中应用swagger2的一个DEMO,主要功能包括:WEB访问API,API导出为adoc、html、pdf。项目中有中文字体文件,使用的时候先删除目录docs、html和pdf目录,启动项目,然后点击...可方便的移植到自己的项目中。
把Android Apidemo第一个例子抽出来,以后每学一节就加进Apidemo框架里,加深理解
百度地图API使用,及Demo。一套应用程序接口,帮助开发者构建功能丰富、交互性强的地图应用程序。 JavaScript API Mobile API Web Services Flash API 导航控件 缩略图控件 地图类型控件 比例尺控件 ...
Android2.3ApiDemo
学习android 的sample apidemo 以后要用到这些例子 方便自己方便别人