We are about to switch to a new forum software. Until then we have removed the registration on this forum.
A few recent posts about P3 issues have the following lines of code (from akenaton) as solution to obtaining context/activity info etc, but they are giving me an error.
The error I am getting is saying that "the function getActivity() does not exist"
import android.content.Context; import android.app.Activity;
Context context;
Activity act;
void setup() {
act = this.getActivity();
context = act.getApplicationContext();
}
void draw() {
}
I could have stayed in one of the current discussions but as this goes across a few I hope another discussion thread is OK!?
Answers
Inside setup(), draw() and other Processing's callbacks,
this
is a PApplet reference:println(this instanceof PApplet);
So does that mean I shouldn't use this in setup and draw? Thanks for fast reply!
It's not it! It just means that getActivity() doesn't exist as a PApplet method.
Actually, we can prefix almost any Processing's API w/
this
. :>Ok got it! Thanks.
getActivity() is NOT a PApplet method;
Yet:: (&& that's i have done) you can get context from application context i have explained how and why
&& show that the android examples (which cannot run) can run if (see my posts)
so you write
then use context...
@akenaton Yes I understand what you did .. And thanks for posting for us! It was just the error being reported that worried me and I didnt know why it was showing. You have helped a lot!
@hudson_m400== thanks because i have not seen any answer from the processing team about that (and about "how P3 android mode is supposed to work"--- very simple???)
---rather :: not work ----try to make a video with it
--if you can, tell me, happy!!!!
either:: tell me
&& i ll explain you what this simplest thing is impossible, because "private" && so on
Processing 3.0 is still under heavy construction since moving the PApplet to it's own fragment. Things might still change a bit inside and lots of stuff need a rewrite.
But mostly it's done and it's only the documentation that needs an update. : )