RMMV Is there any way to remove the game refresh for android?

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
Is there any way to remove the game refresh for android?

I am currently doing tests of my game on android and noticed that sometimes it restarts randomly.

I did a test with a controller and when I turn off the controller the game restarts...:aswt:

I saw that someone made a plugin that disables the F5, but on android obviously, this does not work...
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
It may be a problem with some Plugin:
  1. What version of your Android?
  2. What version of WebView (Android -> Apps)?
  3. What Plugins are you using in your game?
  4. Tried to create a simple game with nothing and compile to APK?
The way that most RpgMV / MZ users create the project (Android Studio) to compile (APK) is based on the manual, but it is not necessarily the only way to do this.

Good Luck
 
Last edited:

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
It may be a problem with some Plugin:
  1. What version of your Android?
  2. What version of WebView (Android -> Apps)?
  3. What Plugins are you using in your game?
  4. Tried to create a simple game with nothing and compile to APK?
The way that most RpgMV / MZ users create the project (Android Studio) to compile (APK) is based on the manual, but it is not necessarily the only way to do this.

Good Luck
Thanks.

1. Android 10
2. 83.0.4103.101
3. A lot of plugins.(Yanfly,Moghunter,HIME...)
4. I have not done this yet, but I downloaded an RPG maker game from playstore, and the same thing happened so it must be something from my android or it must have something to do with the controller I use to play.

I just wanted to find a way to disable the refresh.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
If it is a key called "Page refresh", it is native to the application's mini-browser. Therefore, predicting the F5 key will not work, as it is not the same key, it should be something like this:
JavaScript:
location.reload(); //reload page

Try to put this right in the index.html
I'm away from my computer and Rpg Maker now.
JavaScript:
window.onbeforeunload = function(){
   return "You cannot refresh the page";
}
 

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
Thanks for helping me.
JavaScript:
window.onbeforeunload = function(){
return "You cannot refresh the page";
}

I added this code to index.html

A confirmation window appears on the computer to restart the game.

On android it simply ignores it.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
So, only if we find out what is the key event in your controller that reloads the page.

So we can use:
event.preventDefault();

You can find out what the event is if you can install the controller on your computer.
 

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
So, only if we find out what is the key event in your controller that reloads the page.

So we can use:
event.preventDefault();

You can find out what the event is if you can install the controller on your computer.
From my tests, always when I disconnect and connect the controller from the smartphone the game restarts.
 

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
Please tell the make and model of the device.
I am using a Xiaomi Poco x3
CPU- Qualcomm SM7150-AC Snapdragon 732G,GPU- Adreno 618, 6 GB Ram.
I did a test with Xiaomi note 7 with the controller happened the same thing.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
Sorry, I was referring to the control model, why events happen because of it.

Try modifying the APK:

Feedback please:
You can find out what the event is if you can install the controller on your computer.
 
Last edited:

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
Sorry, I was referring to the control model, why events happen because of it.

Try modifying the APK:

Feedback please:
Ah sorry...

Ipega 9076.

I will try to modify the apk.

On the computer, nothing happened.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
I am thinking of a theory of the cause of the problem.
I think Android (WebView) automatically restarts the page when connecting / disconnecting, to ensure that the command system has been changed.
Perhaps the same can happen when you connect a mouse via USB with "USB-OTG".

Test other games made in RpgMV:
https://play.google.com/store/search?q=rpg maker mv&c=apps
 

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
I am thinking of a theory of the cause of the problem.
I think Android (WebView) automatically restarts the page when connecting / disconnecting, to ensure that the command system has been changed.
Perhaps the same can happen when you connect a mouse via USB with "USB-OTG".

Test other games made in RpgMV:
https://play.google.com/store/search?q=rpg maker mv&c=apps
Yes, it happens in all the other games I tested.:aswt:

So there's not much to do...

Since it happens to everyone.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
Have you ever done the test by running the game on a browser on your smartphone?
(Via HTTP)
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
That's what I thought, the problem must not be in control, it must be in the "plug & play" system.
The fact is that I searched the internet and found nothing about it.
There is no way to be absolutely sure, you have to test all the possibilities, which is not so easy:
  • Place a USB mouse to see if the same happens
  • Place a controller from another brand
  • Test on an older android, preferably 5.0 (Loolip)
Anyway, I wish you the best of luck.
 
Last edited:

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
That's what I thought, the problem must not be in control, it must be in the "plug & play" system.
The fact is that I searched the internet and found nothing about it.
There is no way to be absolutely sure, you have to test all the possibilities, which is not so easy:
  • Place a USB mouse to see if the same happens
  • Place a control from another brand
  • Test on an older android, preferably 5.0 (Loolip)
Anyway, I wish you the best of luck.
Thanks for helping me. I will do more tests soon.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
878
Reaction score
439
First Language
PT-BR
Primarily Uses
RM2k3
I ended up getting some time to create a test code with Javascript. It blocks any key, except the ones used in games made with Rpg MV.

If it does not work then it is sure that it is something in WebView.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Only - RpgMV Keys</title>
<script>
var know, nowkey, MVkey, mytimer, counter;

window.onload=function(){
   nowkey=document.getElementById("nowkey");
   MVkey=document.getElementById("MVkey");
   mytimer=document.getElementById("mytimer");
   counter=0;
   setInterval(function(){counter++;mytimer.innerHTML="Timer: "+counter}, 1000);
}
document.onkeydown=function(e){
   nowkey.innerHTML="Key: ["+e.key+"]";
   if(
      e.key != "ArrowLeft" && e.key.code != "ArrowLeft" &&
      e.key != "ArrowUp" && e.key.code != "ArrowUp" &&
      e.key != "ArrowRight" && e.key.code != "ArrowRight" &&
      e.key != "ArrowDown" && e.key.code != "ArrowDown" &&

      e.key != "Left" &&
      e.key != "Up" &&
      e.key != "Right" &&
      e.key != "Down" &&

      e.key != "Enter" && e.key.code != "Enter" &&
      e.key != "Z" && e.key.code != "KeyZ" &&
      e.key != " " && e.key.code != "Space" &&
      e.key != "Enter" &&
      e.key != "Spacebar" &&

      e.key != "Escape" && e.key.code != "Escape" &&
      e.key != "X" && e.key.code != "KeyX" &&
      e.key != "0" && e.key.code != "Numpad0" &&
      e.key != "Esc" &&

      e.key != "8" && e.key.code != "Numpad8" &&
      e.key != "6" && e.key.code != "Numpad6" &&
      e.key != "2" && e.key.code != "Numpad2" &&
      e.key != "4" && e.key.code != "Numpad4" &&

      e.key != "PageUp" && e.key.code != "PageUp" &&
      e.key != "PageDown" && e.key.code != "PageDown"
   ){
      e.preventDefault();
      return false;
   }else{
      MVkey.innerHTML="MV-Key: ["+e.key+"]";
   }
}
</script>
</head>
<body>
<pre id="nowkey">Key: [false]</pre>
<pre id="MVkey">MV-Key: [false]</pre>
<pre id="mytimer">Timer: 0</pre>
</body>
</html>
 
Last edited:

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
I ended up getting some time to create a test code with Javascript. It blocks any key, except the ones used in games made with Rpg MV.

If it does not work then it is sure that it is something in WebView.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Only - RpgMV Keys</title>
<script>
var know, nowkey, MVkey, mytimer, counter;

window.onload=function(){
   nowkey=document.getElementById("nowkey");
   MVkey=document.getElementById("MVkey");
   mytimer=document.getElementById("mytimer");
   counter=0;
   setInterval(function(){counter++;mytimer.innerHTML="Timer: "+counter}, 1000);
}
document.onkeydown=function(e){
   nowkey.innerHTML="Key: ["+e.key+"]";
   if(
      e.key != "ArrowLeft" && e.key.code != "ArrowLeft" &&
      e.key != "ArrowUp" && e.key.code != "ArrowUp" &&
      e.key != "ArrowRight" && e.key.code != "ArrowRight" &&
      e.key != "ArrowDown" && e.key.code != "ArrowDown" &&

      e.key != "Left" &&
      e.key != "Up" &&
      e.key != "Right" &&
      e.key != "Down" &&

      e.key != "Enter" && e.key.code != "Enter" &&
      e.key != "Z" && e.key.code != "KeyZ" &&
      e.key != " " && e.key.code != "Space" &&
      e.key != "Enter" &&
      e.key != "Spacebar" &&

      e.key != "Escape" && e.key.code != "Escape" &&
      e.key != "X" && e.key.code != "KeyX" &&
      e.key != "0" && e.key.code != "Numpad0" &&
      e.key != "Esc" &&

      e.key != "8" && e.key.code != "Numpad8" &&
      e.key != "6" && e.key.code != "Numpad6" &&
      e.key != "2" && e.key.code != "Numpad2" &&
      e.key != "4" && e.key.code != "Numpad4" &&

      e.key != "PageUp" && e.key.code != "PageUp" &&
      e.key != "PageDown" && e.key.code != "PageDown"
   ){
      e.preventDefault();
      return false;
   }else{
      MVkey.innerHTML="MV-Key: ["+e.key+"]";
   }
}
</script>
</head>
<body>
<pre id="nowkey">Key: [false]</pre>
<pre id="MVkey">MV-Key: [false]</pre>
<pre id="mytimer">Timer: 0</pre>
</body>
</html>
Thanks, I will test it.
 

YioruYioru

Villager
Member
Joined
Mar 31, 2021
Messages
23
Reaction score
4
First Language
Portuguese - BR
Primarily Uses
RMMV
I ended up getting some time to create a test code with Javascript. It blocks any key, except the ones used in games made with Rpg MV.

If it does not work then it is sure that it is something in WebView.

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Only - RpgMV Keys</title>
<script>
var know, nowkey, MVkey, mytimer, counter;

window.onload=function(){
   nowkey=document.getElementById("nowkey");
   MVkey=document.getElementById("MVkey");
   mytimer=document.getElementById("mytimer");
   counter=0;
   setInterval(function(){counter++;mytimer.innerHTML="Timer: "+counter}, 1000);
}
document.onkeydown=function(e){
   nowkey.innerHTML="Key: ["+e.key+"]";
   if(
      e.key != "ArrowLeft" && e.key.code != "ArrowLeft" &&
      e.key != "ArrowUp" && e.key.code != "ArrowUp" &&
      e.key != "ArrowRight" && e.key.code != "ArrowRight" &&
      e.key != "ArrowDown" && e.key.code != "ArrowDown" &&

      e.key != "Left" &&
      e.key != "Up" &&
      e.key != "Right" &&
      e.key != "Down" &&

      e.key != "Enter" && e.key.code != "Enter" &&
      e.key != "Z" && e.key.code != "KeyZ" &&
      e.key != " " && e.key.code != "Space" &&
      e.key != "Enter" &&
      e.key != "Spacebar" &&

      e.key != "Escape" && e.key.code != "Escape" &&
      e.key != "X" && e.key.code != "KeyX" &&
      e.key != "0" && e.key.code != "Numpad0" &&
      e.key != "Esc" &&

      e.key != "8" && e.key.code != "Numpad8" &&
      e.key != "6" && e.key.code != "Numpad6" &&
      e.key != "2" && e.key.code != "Numpad2" &&
      e.key != "4" && e.key.code != "Numpad4" &&

      e.key != "PageUp" && e.key.code != "PageUp" &&
      e.key != "PageDown" && e.key.code != "PageDown"
   ){
      e.preventDefault();
      return false;
   }else{
      MVkey.innerHTML="MV-Key: ["+e.key+"]";
   }
}
</script>
</head>
<body>
<pre id="nowkey">Key: [false]</pre>
<pre id="MVkey">MV-Key: [false]</pre>
<pre id="mytimer">Timer: 0</pre>
</body>
</html>
I don't know if I did it right.

Was I supposed to add it to the index.html?

I tested it and it didn't work.;_;

I noticed that if I disconnect and connect the controller while I use a browser, the browser restarts too.
 

Latest Threads

Latest Profile Posts

I suddenly feel like making a game for little kids: a pointless sandbox of cute animals, silly collectibles, and random mini games.
Anyone else just like, not bother to make games themed around specific holidays? I know I won't get them done in time for it to make sense.
time to enter the playtest dimension
Sherriff: This permit you're renewing expired two months ago, you haven't been concealing illegally have you?

Me, remembering the sheriff was at the range with me a couple weeks ago and unsure if he'd noted me draw from IWB: I plead the fifth.
Stardew Valley's ConcernedApe announced their new game with a teaser. Hyped. It gave me some ideas to think about for the games I'm going to make as well.

Forum statistics

Threads
115,986
Messages
1,094,655
Members
151,270
Latest member
Diablerie
Top