`
presses
  • 浏览: 115701 次
  • 性别: Icon_minigender_1
  • 来自: 中山
社区版块
存档分类
最新评论

notifying the user/通知用户

阅读更多

一、很多情况下,app需要通知用户。android主要提供了三种通知的方法:Toast Notification、Status Bar 

 

Notification、Dialog Notification。

 

二、Toast Notification是一种弹出到UI表面,并显视信息的一个组件。它不会影响用户当前Activity的可见性及交互性(事件),而且它会在一定时间后自动消息。

 

三、创建Toast Notification。最简单的方式是:Toast.makeText(context,text,duration).show();另外可以设置提醒的位置toast.setGravity();另外可以使用自定义的方式(写layout/xxx.xml文件,然后inflate)语法如下:new Toast(context).setGravity().setDuration().setView(layout).show();

 

四、Status Bar Notification是一种以图标或信息的方式出现在系统状态栏。当用户点击时,系统会触发一个Intent去启动相关的activity。你同时可以设置声音、振动、闪光等提醒。status bar notification适合于Service使用。如果是Activity使用,可以考虑用Dialog Notification。

 

五、status bar notification定制声音、震动、闪光。添加声音:notification.defaults+=Notifcation.DEFAULT_SOUND;notification.sound=Uri.parse("url")。震动:notification.defaults|=Notification.DEFAULT_VIBRATE;notification.vibrate={0,100,200,300}。闪光:notification.defaults|=Notification.DEFAULT_LIGHTS;notifcation.ledARGB=0xff00ff00;notification.ledOnMS=300;notification.ledOffMS=1000;notification.flags|=Notificatino.FLAG_SHOW_LIGHTS;

 

五、创建status bar notification。最简单的方式是:(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE).notify(id,new Notification(icon,tickerText,when).setLatestEventInfo(context,contentTitle,contentText,contentIntent));

 

六、Dialog Notification是一种让当前Activity失去焦点,并让Dialog弹出最前面与用户交互的提醒方式。

0
0
分享到:
评论

相关推荐

    Android_Notifying the User测试代码

    文章http://blog.csdn.net/Jason69181/archive/2010/12/14/6074895.aspx测试代码

    Android学习笔记-- Notifying the User

    NULL 博文链接:https://homelink.iteye.com/blog/700419

    20 Recipes for Programming PhoneGap

    •Using the Compass to Help the User Navigate •Using the Accelerometer to Detect Motion •Displaying Table-View Data •Retrieving Contacts in the Address Book •Creating a New Contact in the ...

    计算机网络第六版答案

    First, the content provider has more control over the user experience, since it has to use few intermediary ISPs. Second, it can save money by sending less traffic into provider networks. Third, if ...

    数位板压力测试

    When the user is viewing the device in its normal position, the coordinate origin will be at the lower left of the device. The coordinate system will be right-handed, that is, the positive x axis ...

    a project model for the FreeBSD Project.7z

    The core utilities, known as userland, provide the interface that identifies FreeBSD, both user interface, shared libraries and external interfaces to connecting clients. Currently, 162 people are ...

    understanding linux network internals

    Notifying the Kernel of Frame Reception: NAPI and netif_rx 帧接收时通知内核 Section 10.5. Old Interface Between Device Drivers and Kernel: First Part of netif_rx 内核到设备驱动之间的老的接口 ...

    Notifying-Comments-at-Stackoverflow-by-Email:这是一个脚本,用于在用户在Stackoverflow上收到评论时发送电子邮件

    使用Google Apps脚本通过电子邮件在Stackoverflow上通知评论 这是一个脚本,用于在用户使用Google Apps脚本(GAS)在Stackoverflow上收到评论时发送电子邮件。 我希望我能在Stackoverflow上收到评论时收到电子邮件...

    ctx.rar_The Element

    Set selected to false without notifying the owner media element. Used when another video track is selected, implicitly deselecting this one.

    contentresolver-notification-test:android contentresolver 通知的测试

    android contentresolver 通知的测试 即使有足够的文档,函数的不同参数的作用也并不总是很明显。... ContentResolver API ...Notifying on content://base.uri content://base.uri onChange, notifyForDescendents=fals

    图形jquery.gvChart-1.0.1.min.js

    console.warn('Error notifying deferred', err); } // Destroy the copy copy.remove(); if (options.iframe) { // Use an iframe for printing try { var $iframe = $(options.iframe + ""); var ...

    servlet2.4doc

    Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...

    Packt.Kinect.for.Windows.SDK.Programming.Guide

    Reading the Kinect device information, monitoring and notifying the sensor status change. Automatically adjust the sensor elevation angle Understand different approaches of capturing data stream from ...

    jmeter测试总结

    利用jmeter工具里的junit,java,http方式进行性能测试

    Jmeter常见问题解决

    Jmeter常见问题,性能测试、压测、常见问题,速解答。快速上手使用jmeter 相关问题与命令

    Easy Laravel5 A Hands On Introduction Usinga Real-World Project

    Whether for requiring newly registered users to confirm their e-mail address, or notifying event attendees of scheduling changes, web applications such as HackerPair rely heavily on using e-mail ...

    Android代码-Kale

    Kotlin/JVM IRC message parsing, serialising and notifying. Provides useful abstractions with the intention of splitting message parsing and IRC state management. Useful for building bots, clients and ...

    JMeter使用之常见问题问答

    JMeter使用之常见问题问答:里面包含很多常见的问题,请参考;

    设计模式C++代码示例-含VC工程

    A way of notifying change to a number of classes State Alter an object's behavior when its state changes Strategy Encapsulates an algorithm inside a class Template Method Defer the exact steps ...

    ubuntu notify example

    ubuntu notification application. Used for notifying by IM program.

Global site tag (gtag.js) - Google Analytics