欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android中通知欄跳動問題解決方法

 更新時間:2015年01月19日 08:57:08   投稿:junjie  
這篇文章主要介紹了Android中通知欄跳動問題解決方法,導致這個問題的原因是when這個屬性值,默認它是使用的系統當前時間,這就是導致跳動問題的原因,指定一個固定時間即可解決這個問題,需要的朋友可以參考下

曾經遇到過這樣的問題,在我的代碼中使用了通知欄,一切都正常,但是就是正在進行的通知欄中屬于我的程序的那一條總是上下跳來跳去,一閃一閃的。感覺用戶體驗很不好,于是Google一下,找到了解決方法。

在我的代碼,我是這樣寫的。

復制代碼 代碼如下:

notification.when = System.currentTimeMillis();

這就是問題的關鍵,對于通知來說,when這個屬性值應該在activity一啟動的時候就應該固定。如果沒有固定,就會使用默認的值,默認的值就是當前的時間,即System.currentTimeMillis()的值。因此使用一個自定義的固定值就可以解決問題。

復制代碼 代碼如下:

final long TIMESTAMP_FIXED = 1234567890l;
notification.when = TIMESTAMP_FIXED;

以下如Google介紹如何使用notification的when的說明。

復制代碼 代碼如下:

A timestamp related to this notification, in milliseconds since the epoch. Default value: Now. Choose a timestamp that will be most relevant to the user. For most finite events, this corresponds to the time the event happened (or will happen, in the case of events that have yet to occur but about which the user is being informed). Indefinite events should be timestamped according to when the activity began. Some examples:

Notification of a new chat message should be stamped when the message was received.
Notification of an ongoing file download (with a progress bar, for example) should be stamped when the download started.
Notification of a completed file download should be stamped when the download finished.
Notification of an upcoming meeting should be stamped with the time the meeting will begin (that is, in the future).
Notification of an ongoing stopwatch (increasing timer) should be stamped with the watch's start time.
Notification of an ongoing countdown timer should be stamped with the timer's end time.

Reference

http://developer.android.com/reference/android/app/Notification.html#when

相關文章

  • Android編程之短信竊聽器實現方法

    Android編程之短信竊聽器實現方法

    這篇文章主要介紹了Android編程之短信竊聽器實現方法,以實例形式較為詳細的分析了Android編程實現竊聽器的具體步驟與實現技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-11-11
  • Android實現環(huán)形進度條代碼

    Android實現環(huán)形進度條代碼

    這篇文章主要為大家詳細介紹了Android實現環(huán)形進度條的代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Android EditText實現輸入表情

    Android EditText實現輸入表情

    editText是TextView的子類,TextView能用的工具EditText都能用,接下來通過實例代碼給大家分享Android EditText實現輸入表情功能,感興趣的朋友一起看看吧
    2017-08-08
  • Android Selector 按下修改背景和文本顏色的實現代碼

    Android Selector 按下修改背景和文本顏色的實現代碼

    這篇文章主要介紹了Android Selector 按下修改背景和文本顏色的實現代碼,本文通過實例代碼和demo展示給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-11-11
  • Android原生實現多線程斷點下載實例代碼

    Android原生實現多線程斷點下載實例代碼

    本篇文章主要介紹了Android原生實現多線程斷點下載實例代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Android對EditTex的圖片實現監(jiān)聽

    Android對EditTex的圖片實現監(jiān)聽

    這篇文章主要為大家詳細介紹了Android如何對EditTex的圖片實現監(jiān)聽,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Android自定義圓形View實現小球跟隨手指移動效果

    Android自定義圓形View實現小球跟隨手指移動效果

    這篇文章主要為大家詳細介紹了Android自定義圓形View實現小球跟隨手指移動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • Flutter自定義實現神奇動效的卡片切換視圖的示例代碼

    Flutter自定義實現神奇動效的卡片切換視圖的示例代碼

    這篇文章主要介紹了Flutter自定義實現神奇動效的卡片切換視圖的示例代碼,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-04-04
  • Android編程實現微信分享信息的方法

    Android編程實現微信分享信息的方法

    這篇文章主要介紹了Android編程實現微信分享信息的方法,實例分析了Android官方demo示例,講述了Android微信分享功能的具體實現技巧,需要的朋友可以參考下
    2015-10-10
  • Android自定義view實現側滑欄詳解

    Android自定義view實現側滑欄詳解

    之前一直沒有寫側滑菜單的實現方法,今天計劃補上。手機開發(fā)中,往往存在很多功能沒處放的問題。我們可能會把功能放入一個菜單列表,但現在一種流行的做法是側滑菜單
    2022-11-11

最新評論