zoukankan      html  css  js  c++  java
  • notification

    3种notification:

    1. Dialog 循环进度条:适合前端activity。

    2. Toast: 不需要用户干预, service也可。

    默认: Toast.makeText(context, text, duration).show();
    设置显示位置:toast.setGravity(Gravity.CENTER_VERTICAL,0,0);
    自定义view:toast.setView(layout);

    3. Status notification: 适合service引起用户注意。

    Status notification较复杂,如下:

    1、获得service:nm = getSystemService(Context.NOTIFICATION_SERVICE);

    2、定义PendingIntent:PendingIntent.getActivity(this, 0, new Intent(this, MyClass.class), 0);

    3、定义notification:new Notification(icon, text, when).setLatestEventInfo(context, tiltel, text, pendingIntent);

      notification包括(具体见源代码):

        icon:显示在状态栏;

        可选的ticker-text:显示在状态栏的简单消息;

        下拉中的通知内容:默认是title、message;可自定义layout,使用满足RemoteView的控件,notification.contentIntent = pendingIntent

        PendingIntent:用户选中通知后发送该intent给Android处理;

        可选的sound、震动、led;

        可选的flag:FLAG_AUTO_CANCEL用户点击后自动消失;FLAG_INSISTENT重复sound;FLAG_ONGOING_EVENT;FLAG_NO_CLEAR不可清除;number通知的事件个数;iconLevel同LevelListDrawable在状态栏显示不同icon;

    4、发通知:nm.notify(ID, notification);

      ID,标识不同通知,cancel(id)主动销毁。

    5、更新通知:setLatestEventInfo(),notify(ID,not);

  • 相关阅读:
    CI(CodeIgniter)框架介绍
    yii框架
    Jenkins简单使用介绍
    UNITY_INITIALIZE_OUTPUT宏
    UNITY地图寻路及服务器解决方案
    bloom
    Rigidbody中 Angular Drag (角阻力):
    Unity5 Shader Stripping 导致 LightMap 全部丢失的解决方法
    移动端播放视频文件
    UNITY5 为什么Inspector视图中脚本前面的勾选框没了
  • 原文地址:https://www.cnblogs.com/toven/p/2659069.html
Copyright © 2011-2022 走看看