Skip to content

Commit

Permalink
allow app to run on Android 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioCZ committed Jan 21, 2019
1 parent 23651c1 commit 53d2b15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "com.gottlicher.notifrepeater"
minSdkVersion 26
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.1.1"
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
1 change: 1 addition & 0 deletions app/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ private AlertDialog buildNotificationServiceAlertDialog(){
}

private void createNotificationChannel() {
CharSequence name = getString(R.string.notif_channel_name);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
return;
}
CharSequence name = getString(R.string.notif_channel_name);
String description = getString(R.string.notif_channel_name);
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel channel = new NotificationChannel(NotifListenerService.CHANNEL_ID, name, importance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ void postRepeatNotification(StatusBarNotification sbn) {

public static void postNotification(Context context, String title, String text, int icon, PendingIntent clickIntent, int id)
{
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(icon)
NotificationCompat.Builder mBuilder;

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mBuilder = new NotificationCompat.Builder(context, CHANNEL_ID);
} else {
mBuilder = new NotificationCompat.Builder(context);
}

mBuilder.setSmallIcon(icon)
.setContentTitle(title)
.setContentText(text)
.setContentIntent(clickIntent)
Expand Down

0 comments on commit 53d2b15

Please sign in to comment.