- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
android wear开发之创建通知android wear开发之创建通知
为了创建一个手持设备上的并且也能同时发送给可穿戴设备的Notification,需要使用NotificationCompat.Builder。当你使用这个类创建Notification之后,如何正确展示的工作就交由系统去完成,无论是在手持式设备上还是可穿戴设备上。 导入必要的包,在你的build.gradle文件中加入下面这行: compile com.android.support:support-v4:20.0.+ 现在,您的项目已经获得必要的包,从支持库导入必要的类: import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationCompat.WearableExtender; 通过Notification Builder创建Notification v4 support library能够让你采用必威体育精装版的特性,诸如放置action button或采用large icon,去实现一个Notification,兼容Android1.6(API level4)及以上。 为了通过support library创建一个Notification,你需要创建一个NotificationCompat.Builder的实例,然后通过notify()去激活。 例如: int notificationId = 001; // Build intent for notification content Intent viewIntent = new Intent(this, ViewEventActivity.class); viewIntent.putExtra(EXTRA_EVENT_ID, eventId); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_event) .setContentTitle(eventTitle) .setContentText(eventLocation) .setContentIntent(viewPendingIntent); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Build the notification and issues it with notification manager. notificationManager.notify(notificationId, notificationBuilder.build()); 当该Notification出现在手持设备上时,用户能够通过触摸Notification来触发之前通过setContentIntent()设置的PendingIntent。当该Notification出现在可穿戴设备上时,用户能够通过向左滑动该Notification显示Open的action,点击这个action能够触发响应的Intent,就可以作用在手持设备上。 添加Action按钮 除了通过setContentIntent()定义的主要的action之外,你还可以通过传递一个PendingIntent给addAction()的参数,从而添加更多的action。例如,下面的代码展示了同上面一样的Notification,只不过添加了一个在地图上查看事件位置的action。 // Build an intent for an action to view a map Intent mapIntent = new Intent(Intent.ACTION_VIEW); Uri geoUri = Uri.parse(geo:0,0?q= + Uri.encode(location)); mapIntent.setData(geoUri); PendingIntent mapPendingIntent = PendingIntent.getAc
您可能关注的文档
- A comparative study on wedding customs in differenA comparative study on wedding customs in differen.doc
- A Design of DES Encryption Chip with Resistance to Differential Power AnalysisA Design of DES Encryption Chip with Resistance to Differential Power Analysis.doc
- A dill Pickle评论一篇 英文A dill Pickle评论一篇 英文.doc
- A Glimpse of Chinese Culture chapter1-8A Glimpse of Chinese Culture chapter1-8.doc
- A hotter climate could make some plants move downhill to seek waterA hotter climate could make some plants move downhill to seek water.doc
- A introduction to Database Management System Raghu RamakrishnanA introduction to Database Management System Raghu Ramakrishnan.doc
- A Logical Model of Private International Law1 IntroductionA Logical Model of Private International Law1 Introduction.doc
- A man is not old as long as he is seeking somethingA man is not old as long as he is seeking something.doc
- A MisunderstandinA Misunderstandin.doc
- A Narrative Inquiry into The comparisons of EnglisA Narrative Inquiry into The comparisons of Englis.doc
- Android adb 命令图解Android adb 命令图解.docx
- android wear开发之绘制表盘android wear开发之绘制表盘.doc
- android屏幕自适应 android 属性android屏幕自适应 android 属性.doc
- Android地图和定位实现Android地图和定位实现.docx
- Android数据存储_ORM框架之greenDAO(杰瑞教育原创)Android数据存储_ORM框架之greenDAO(杰瑞教育原创).docx
- Android源码分析-Activity的启动过程Android源码分析-Activity的启动过程.doc
- Android错误集锦!Android错误集锦!.docx
- AndroVM 可以让你在虚拟机环境中运行 AndroidAndroVM 可以让你在虚拟机环境中运行 Android.doc
- Animation Modeling with Chu Art Characteristics Based on1Animation Modeling with Chu Art Characteristics Based on1.docx
- Another School YearAnother School Year.docx
文档评论(0)