# Android notification pls help

**URL:** <https://discourse.processing.org/t/android-notification-pls-help/33309>\
**Category:** Processing for Android\
**Created:** [November 4, 2021, 10:47am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309 "2021-11-04T10:47:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [November 4, 2021, 10:47am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/1 "2021-11-04T10:47:17Z")

</div>

Hello i want thus and i found thus Code but don’t Work!

```auto

import android.app.NotificationChannel;
import android.app.NotificationManager;

import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;

import static android.content.Context.NOTIFICATION_SERVICE;

String CHANNEL_ID = "processing_test.notifications";

void setup() {
  fullScreen();
  initNotifications();
}

void draw() {
  background(150);
}

void mousePressed() {
  showNotification();
}

void initNotifications() {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    // Create the NotificationChannel, but only on API 26+ because
    // the NotificationChannel class is new and not in the support library
    String name = "Test Notifications";
    String description = "Notifications from Processing sketch are shown in this channel";
    int importance = NotificationManager.IMPORTANCE_HIGH;
    NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
    channel.setDescription(description);
    // Register the channel with the system
    NotificationManager notificationManager = (NotificationManager)
      getContext().getSystemService(NOTIFICATION_SERVICE);
    notificationManager.createNotificationChannel(channel);
  }
}

void showNotification() {
  // Create an explicit intent for an Activity in your app
  NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext(), CHANNEL_ID)
    .setSmallIcon(R.drawable.icon)
    .setContentTitle("This is a messsage")
    .setContentText("Mouse pressed event detected!")
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
    .setPriority(NotificationCompat.PRIORITY_HIGH)
    .setAutoCancel(true);

  // Show the notification
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getContext());
  // notificationId is a unique int for each notification that you must define
  int notificationId = 666;
  notificationManager.notify(notificationId, mBuilder.build());
}

```

[main|400x500](https://discourse.processing.org/uploads/short-url/lj3PKKFl8kO9S8HJAIGRqVZXstR.jpg)

---

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [November 4, 2021, 10:48am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/2 "2021-11-04T10:48:24Z")

</div>

I become rhe Error: ----------

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing\_test/notifications/nachriten.java (at line 69)  
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext(), CHANNEL\_ID)  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
The constructor NotificationCompat.Builder(Context, String) is undefined

* * *

---

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [November 4, 2021, 10:50am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/3 "2021-11-04T10:50:36Z")

</div>

@GWAK or @noel @Andres @kfrajer

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 5, 2021, 12:16am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/4 "2021-11-05T00:16:02Z")

</div>

@MonteliaRO

What about your version information?

Settings vary depending on the situation.

Reference site:

> [@\[Android\] I can't find a solution. 'Notification pop up' is required](https://discourse.processing.org/t/android-i-cant-find-a-solution-notification-pop-up-is-required/14961):
>
> [Android] I can’t find a solution. ‘Notification pop up’ is required. Reference: [[Android] 'Notification' does not work](https://discourse.processing.org/t/android-notification-does-not-work/14512) ‘Notification pop up’ doesn’t work after Android version is higher. Can anyone solve it? Please help me. I want to solve import android.os.Build; import android.app.NotificationChannel; import android.app.NotificationManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import static android.content.…

```auto
void showNotification() {
// Create an explicit intent for an Activity in your app
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext())

.setSmallIcon(R.drawable.icon)
.setContentTitle("This is a messsage")
.setContentText("Mouse pressed event detected!")
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true);
// Show the notification
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(getContext());
// notificationId is a unique int for each notification that you must define
int notificationId = 666;
notificationManager.notify(notificationId, mBuilder.build());
}

```

---

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [November 10, 2021, 8:33pm UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/5 "2021-11-10T20:33:57Z")

</div>

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20211110a/sketch\_20211110a.java (at line 49)  
if (Build.VERSION.SDK\_INT \>= Build.VERSION\_CODES.O) {  
^^^^^  
Build cannot be resolved

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20211110a/sketch\_20211110a.java (at line 49)  
if (Build.VERSION.SDK\_INT \>= Build.VERSION\_CODES.O) {  
^^^^^  
Build cannot be resolved

* * *

Edit: now ist Work but i don’t get the notification when i Press @GWAK

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 10, 2021, 11:37pm UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/6 "2021-11-10T23:37:06Z")

</div>

@MonteliaRO

1. What is your processing version?
2. What is your Android version?
3. What is the SDK version?

Should I tell you about it so that I can’t interpret it?

---

<div class="post-metadata">

**Author:** ![MonteliaRO](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monteliaro/32/8303_2.png) [@MonteliaRO](https://discourse.processing.org/u/MonteliaRO)\
**Post date:** [November 11, 2021, 12:17am UTC](https://discourse.processing.org/t/android-notification-pls-help/33309/7 "2021-11-11T00:17:37Z")

</div>

My Processing Version is: 0.5.1  
Android ver: 10  
SDK idk what this is
