forked from c-kzxvldkhX/receiptnotice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/weihuagu/receiptnotice/NotificationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Created By WeihuaGu (email:[email protected]) | ||
* Copyright (c) 2017 | ||
* All right reserved. | ||
*/ | ||
|
||
package com.weihuagu.receiptnotice; | ||
import android.app.Notification; | ||
import android.os.Bundle; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
|
||
|
||
public class NotificationUtil { | ||
private static String getNotitime(Notification notification){ | ||
|
||
long when=notification.when; | ||
Date date=new Date(when); | ||
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
String notitime=format.format(date); | ||
return notitime; | ||
|
||
} | ||
|
||
private static String getNotiTitle(Bundle extras){ | ||
String title=null; | ||
// 获取通知标题 | ||
title = extras.getString(Notification.EXTRA_TITLE, ""); | ||
return title; | ||
} | ||
|
||
private static String getNotiContent(Bundle extras){ | ||
String content=null; | ||
// 获取通知内容 | ||
content = extras.getString(Notification.EXTRA_TEXT, ""); | ||
return content; | ||
} | ||
|
||
public static void printNotify(Notification notification){ | ||
LogUtil.debugLog(getNotitime(notification)); | ||
LogUtil.debugLog(getNotiTitle(notification.extras)); | ||
LogUtil.debugLog(getNotiContent(notification.extras)); | ||
} | ||
|
||
} |