Android:充電狀態、輪詢、電池狀態、Notification

Android的充電狀態、電池狀態檢測,Notification聲音設置、點擊提示不彈出新Activity的解決辦法


Android 監控手機電池的狀態(引申爲可以監控手機usb線的插拔事件的監聽)

http://blog.csdn.net/sky181772733/article/details/7377799


Android AlarmManager實現不間斷輪詢服務

http://blog.csdn.net/ryantang03/article/details/9317499


Android Notification 詳解,MediaPlayer 一直播放系統鈴聲

http://www.open-open.com/lib/view/open1378263855687.html


android Notification的一個簡單應用(在Notification中嵌入一個進度條,並且這個Notification點擊消失但不會跳轉)

http://www.kankanews.com/ICkengine/archives/85654.shtml

最後一篇可能會有死鏈接,轉載如下:

  網上很多的例子都是直接獲取Notification對象來設置一個通知,其實Notification跟Dialog一樣,也有自己的Builder,可以用builder對象來設置一個Notification

    這個例子是在Notification中嵌入一個進度條,並且這個Notification點擊消失但不會跳轉(跟android的vcard文件導入時彈出的Notification一樣)

NotificationManager mNotificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder builder = new Notification.Builder(context);
        builder.setOngoing(true);
        builder.setProgress(total, current, false);//設置進度條,false表示是進度條,true表示是個走馬燈
        builder.setTicker(title);//設置title
        builder.setWhen(System.currentTimeMillis());
        builder.setContentTitle(content);//設置內容
        builder.setAutoCancel(true);//點擊消失
        builder.setSmallIcon(R.drawable.upload);
        builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0));//這句和點擊消失那句是“Notification點擊消失但不會跳轉”的必須條件,如果只有點擊消失那句,這個功能是不能實現的
        Notification noti = builder.getNotification();
        mNotificationManager.notify(id,noti);

   

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章