-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加localNotificationCompat依赖v4 25版本,兼容8.0
- Loading branch information
Showing
2 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
library/src/main/java/android/support/v4/app/LocalNotificationCompat.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,62 @@ | ||
package android.support.v4.app; | ||
|
||
import android.app.Notification; | ||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Created by ucmed on 2018/3/8. | ||
*/ | ||
public class LocalNotificationCompat extends NotificationCompat { | ||
public static class Builder extends NotificationCompat.Builder{ | ||
String mChannelId; | ||
/** | ||
* Constructor. | ||
* | ||
* Automatically sets the when field to {@link System#currentTimeMillis() | ||
* System.currentTimeMillis()} and the audio stream to the | ||
* {@link Notification#STREAM_DEFAULT}. | ||
* | ||
* @param context A {@link Context} that will be used to construct the | ||
* RemoteViews. The Context will not be held past the lifetime of this | ||
* Builder object. | ||
* @param channelId The constructed Notification will be posted on this | ||
* NotificationChannel. | ||
*/ | ||
public Builder(@NonNull Context context, @NonNull String channelId) { | ||
super(context); | ||
mContext = context; | ||
mChannelId = channelId; | ||
|
||
// Set defaults to match the defaults of a Notification | ||
mNotification.when = System.currentTimeMillis(); | ||
mNotification.audioStreamType = Notification.STREAM_DEFAULT; | ||
mPriority = PRIORITY_DEFAULT; | ||
mPeople = new ArrayList<String>(); | ||
} | ||
|
||
/** | ||
* @deprecated use {@link #LocalNotificationCompat.Builder(Context,String)} instead. | ||
* All posted Notifications must specify a NotificationChannel Id. | ||
*/ | ||
@Deprecated | ||
public Builder(Context context) { | ||
this(context, null); | ||
} | ||
|
||
|
||
/** | ||
* Specifies the channel the notification should be delivered on. | ||
* | ||
* No-op on versions prior to {@link android.os.Build.VERSION_CODES#O} . | ||
*/ | ||
public Builder setChannelId(@NonNull String channelId) { | ||
mChannelId = channelId; | ||
return this; | ||
} | ||
} | ||
|
||
|
||
} |
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