How do I setup an Android Notification Channel?
up vote
0
down vote
favorite
I looked at the example code Android "Create a Notification" example and created my own version of it:
import android.support.v4.app.NotificationCompat;
...
Notification notification = new NotificationCompat.Builder(this, (String) CHANNEL_ID)
.setContentTitle("Eumag")
.setContentText("foreground service running")
.setSmallIcon(R.drawable.ic_android)
.setContentIntent(pendingIntent)
.build();
However, that yielded this error when I tried to build the project:
error: constructor Builder in class Builder cannot be applied to given
types; required: Context found: ForegroundService,String reason:
actual and formal argument lists differ in length
I did some research and found out that it means that there is no constructor that accept the given parameters. So I looked into the NotificationCompat.Builder documents. According to the docs, both of the following methods should exist, but in the source code, only one of them does:
NotificationCompat.Builder(Context context) [Exists]
NotificationCompat.Builder(Context context, String channelId) [Doesn't Exist]
That's fine I guess, so I go try an alternative which is "setChannelId(String channelId)" and that's not in there either! I AM CONFUSION.
build.gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eumag"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':spotify-app-remote')
implementation "com.google.code.gson:gson:2.6.1"
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
implementation 'com.github.spotify:android-auth:9425c6a140'
implementation 'com.github.nkzawa:socket.io-client:0.3.0'
}
android service notifications channel
add a comment |
up vote
0
down vote
favorite
I looked at the example code Android "Create a Notification" example and created my own version of it:
import android.support.v4.app.NotificationCompat;
...
Notification notification = new NotificationCompat.Builder(this, (String) CHANNEL_ID)
.setContentTitle("Eumag")
.setContentText("foreground service running")
.setSmallIcon(R.drawable.ic_android)
.setContentIntent(pendingIntent)
.build();
However, that yielded this error when I tried to build the project:
error: constructor Builder in class Builder cannot be applied to given
types; required: Context found: ForegroundService,String reason:
actual and formal argument lists differ in length
I did some research and found out that it means that there is no constructor that accept the given parameters. So I looked into the NotificationCompat.Builder documents. According to the docs, both of the following methods should exist, but in the source code, only one of them does:
NotificationCompat.Builder(Context context) [Exists]
NotificationCompat.Builder(Context context, String channelId) [Doesn't Exist]
That's fine I guess, so I go try an alternative which is "setChannelId(String channelId)" and that's not in there either! I AM CONFUSION.
build.gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eumag"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':spotify-app-remote')
implementation "com.google.code.gson:gson:2.6.1"
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
implementation 'com.github.spotify:android-auth:9425c6a140'
implementation 'com.github.nkzawa:socket.io-client:0.3.0'
}
android service notifications channel
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
1
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I looked at the example code Android "Create a Notification" example and created my own version of it:
import android.support.v4.app.NotificationCompat;
...
Notification notification = new NotificationCompat.Builder(this, (String) CHANNEL_ID)
.setContentTitle("Eumag")
.setContentText("foreground service running")
.setSmallIcon(R.drawable.ic_android)
.setContentIntent(pendingIntent)
.build();
However, that yielded this error when I tried to build the project:
error: constructor Builder in class Builder cannot be applied to given
types; required: Context found: ForegroundService,String reason:
actual and formal argument lists differ in length
I did some research and found out that it means that there is no constructor that accept the given parameters. So I looked into the NotificationCompat.Builder documents. According to the docs, both of the following methods should exist, but in the source code, only one of them does:
NotificationCompat.Builder(Context context) [Exists]
NotificationCompat.Builder(Context context, String channelId) [Doesn't Exist]
That's fine I guess, so I go try an alternative which is "setChannelId(String channelId)" and that's not in there either! I AM CONFUSION.
build.gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eumag"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':spotify-app-remote')
implementation "com.google.code.gson:gson:2.6.1"
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
implementation 'com.github.spotify:android-auth:9425c6a140'
implementation 'com.github.nkzawa:socket.io-client:0.3.0'
}
android service notifications channel
I looked at the example code Android "Create a Notification" example and created my own version of it:
import android.support.v4.app.NotificationCompat;
...
Notification notification = new NotificationCompat.Builder(this, (String) CHANNEL_ID)
.setContentTitle("Eumag")
.setContentText("foreground service running")
.setSmallIcon(R.drawable.ic_android)
.setContentIntent(pendingIntent)
.build();
However, that yielded this error when I tried to build the project:
error: constructor Builder in class Builder cannot be applied to given
types; required: Context found: ForegroundService,String reason:
actual and formal argument lists differ in length
I did some research and found out that it means that there is no constructor that accept the given parameters. So I looked into the NotificationCompat.Builder documents. According to the docs, both of the following methods should exist, but in the source code, only one of them does:
NotificationCompat.Builder(Context context) [Exists]
NotificationCompat.Builder(Context context, String channelId) [Doesn't Exist]
That's fine I guess, so I go try an alternative which is "setChannelId(String channelId)" and that's not in there either! I AM CONFUSION.
build.gradle
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.eumag"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':spotify-app-remote')
implementation "com.google.code.gson:gson:2.6.1"
implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
implementation 'com.github.spotify:android-auth:9425c6a140'
implementation 'com.github.nkzawa:socket.io-client:0.3.0'
}
android service notifications channel
android service notifications channel
edited Nov 21 at 4:04
asked Nov 21 at 0:20
Johnny Boy
614
614
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
1
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07
add a comment |
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
1
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
1
1
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403578%2fhow-do-i-setup-an-android-notification-channel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Which version of the support libraries are you using? Note that the two-parameter constructor wasn't added until version 26.1.0.
– Mike M.
Nov 21 at 0:56
1
Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 at 3:16
My build.gradle doesn't look like his though... I'm assuming I need to implement the most recent support library then? If so, how do I go about doing that?
– Johnny Boy
Nov 21 at 4:07