Quantcast
Viewing all articles
Browse latest Browse all 941

Notifications in Android Mode

Hi! I'd like to have notifications in my app, but I know that the way in which a processing sketch works on Android is a bit different; I've been able to include toast notifications (that we can see when the app is on the screen), using the Android constructors.

A piece of code for Toast Notifications:

// The Looper is necessary for displaying Toast Notifications
import android.os.Looper;
import android.widget.Toast;

class TOASTnotifications extends Thread {

  // Text of the notification
  String txt = t;
  // Duration of the notification
  int time = n;

  public TOASTnotifications (String t, int n) {
    txt= t;
    time = n;
  }


  public void start() {
    super.start();
  }

  //@Override
    public void run() {

    Looper.prepare();

    Toast.makeText(this, txt, time).show();

    Looper.loop();
  }

}

But I'd like to see notifications in the android notification center, and then return to the app when I click on them.

Thanks in advance for any help


Viewing all articles
Browse latest Browse all 941

Trending Articles