How do I setup an Android Notification Channel?












0














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'
}









share|improve this question
























  • 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 '18 at 0:56






  • 1




    Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
    – Jantzilla
    Nov 21 '18 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 '18 at 4:07
















0














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'
}









share|improve this question
























  • 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 '18 at 0:56






  • 1




    Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
    – Jantzilla
    Nov 21 '18 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 '18 at 4:07














0












0








0







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'
}









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 4:04

























asked Nov 21 '18 at 0:20









Johnny Boy

1007




1007












  • 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 '18 at 0:56






  • 1




    Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
    – Jantzilla
    Nov 21 '18 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 '18 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 '18 at 0:56






  • 1




    Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
    – Jantzilla
    Nov 21 '18 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 '18 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 '18 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 '18 at 0:56




1




1




Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 '18 at 3:16




Possible duplicate of NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification
– Jantzilla
Nov 21 '18 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 '18 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 '18 at 4:07












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin