1 question: No, you cannot : that is absolutely the user right to leave your app: you can only detect wether the back button was pressed and do someting (saving some var, scores and so on) with onPause();
2 question: i dont understand, of course keyPressed is recognized; as for korean that is a big problem; you can define what language is used (settings of the phone) but if the korean package is not installed you can do noting except asking to your app user to download and install it…
Thinking better I think Akenaton is right. The back button is for returning to last activity. So it’s better to let user make the choise. Code below works on my Kitkat and Lollipop. Did not test it on other.
@GWAK
As for the second question; If I understand it well, the korean keyboard has 10 vowels and 14 consonants which are combined together in a figure representing a syllable.
You say that the the keyPressed() is not recognized, but what do you mean? is it the ‘key’ or the ‘keyCode’ because the last one should work .
The keyCodes you can find here.
You could also remap for non-latin. see here
@GWAK Strange! What version of android do you use? The phone seems to be a Samsung, is that right? ? Can you capture a println() in the onBackPressed?
If you leave out any code in the onBackPressed does it ignore the back key then?
What does code below do? (Do not leave out draw())
@GWAK
Unfortunately I do not have a Marshmallow to test.
You did not answer the question, “If you leave out any code in the onBackPressed does it ignore the back key then?”.
@GWAK@noel ===
as for the 1 point: code from @noel works (i have tested it with kitKat but i dont think that this is important; however i ll test ASAP with MM); it works because P5 has added (i dont know when and why) onBackPressed() from its own in the MainActivity. Yet, if you dont call this method in your fragment code the result is the standard one: the activity is killed. “4” is absolutely normal, it means that the backpressed event was detected (“3” is for home, “4” for back)
as for the second point i cannot see another way to solve that except doing what i have explained a) testing wether the package is present b) if not asking the user to download it and install it
@GWAK
I do understand that it reads the key Code in keyPress().
You can use this to store some bars in onPause().
But I am talking about the onBackPressed() function.
If you just write the function without any instruction in it. It should block the back key. Maybe you can try this on other devices, because it is possible, that after Lollipop Android “fixed” the trick because it is widely “not” recommended.
I only use it because the virtual back button on my device is very close to the bottom, and I am touching it unintentionally all the time. Very annoying! I would like to know if that is the case.(not working after Lollipop)
I know about onPause (), onBackPressed ().
I know the above function works when I press the back button.
So far, the only way to stop it is to re-run it.
But what I want is … (to see video)
If you look at the video, pressing the back button does not turn off the application and the diolog function is turned off.
I want to make it this way. Is there a way?
Hi guys, I just read the post and I can’t contribute too much, but using an android 6 my tablet works badly using processing, maybe that is relevant (the android version)
@Waboqueox
What do you mean by “works badly”?
I am using APDE. A great app, entirely build on the work of the Processing for Android group. It has however the advantage of previewing the sketch, which runs the sketch in seconds. As a hobby programmer, debugging all the time this is important.
I don’t use a desktop anymore.