Android Notification

Can someone Help me i need this for my Game

Not sure its entirely possible processing seems limited to one activity.

I have 3 err.

----------
1. ERROR in /data/user/0/com.calsignlabs.apde/app_build/src/processing/test/sketch_20210326i/sketch_20210326i.java (at line 36)
	String txt = t;
	             ^
t cannot be resolved
----------
2. ERROR in /data/user/0/com.calsignlabs.apde/app_build/src/processing/test/sketch_20210326i/sketch_20210326i.java (at line 40)
	int time = n;
	           ^
n cannot be resolved
----------
3. ERROR in /data/user/0/com.calsignlabs.apde/app_build/src/processing/test/sketch_20210326i/sketch_20210326i.java (at line 74)
	Toast.makeText(this, txt, time).show();
	      ^^^^^^^^
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (TOASTnotifications, String, int)
----------
3 problems (3 errors)

Read the errors. The first 2 say they cant find variables whilst the last one says there is no method makeText that takes 3 params. So check the method or add the method and initialise your variables.

and how do i add them? I’ve never done it before

@paulgoux can you Help me?

Do you have the full code? Ill take a look when i get a mo

@Rogo === as for the 2 first errors we have to see the code as @paulgoux said; as for the 3 error (toast) toast is waiting a context; as for the notification you can do that with P5 because it is a service.

Yes one Moment please

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();

  }

 

}


is this the complete code, it seems incomplete?

Yes its the full Code :confused:

Little lost is this your own code or something you found online.

In any case some variables at least from what i can see are never initialised so i would probably suggest that first.

Can’t someone tell me what to do and how to do it? I don’t know how to do it

Then place at the top of your sketch.

String txt = "sometext" ;

  // Duration of the notification

  int time = 1;

However the better question would be is how much understanding do you have about coding? If you are struggling with variables then this project is likely going to be difficult.

I now only have this one error

----------
1. ERROR in /data/user/0/com.calsignlabs.apde/app_build/src/processing/test/sketch_20210328f/sketch_20210328f.java (at line 72)
	Toast.makeText(this, txt, time).show();
	      ^^^^^^^^
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (TOASTnotifications, String, int)
----------

I only have difficulties with my English because I come from Germany

In any case i still get errors after attempting to build this. For some reason its confusing the string for a charSequence and doesnt know how to resolve it.

Might be able to help you further. I do not understand all the complexities of android coding so id have to do some research before having the answer.

Our old friend Noel did a lot of work in android and ive checked his github but no luck. So you have to be patient, because again its not my area of expertise.

Also its looking for a context and not a toast notification.

At this point though all im doing is trying to understand the error.

https://docs.huihoo.com/android/3.0/guide/topics/ui/notifiers/toasts.html

And finally

These shoulde have the answer you’re looking for.

1 Like

Nice thank you :slight_smile:

1 Like