• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android [SOLVED] import java extension ${YYAndroidPackageName}.R - ${YYAndroidPackageName.RunnerActivity

H

HW.

Guest
I want to ask YoYo team, or anyone else who has experiences to answer this specific question about the RunnerActivity of the GMS2 engine, for the sole purpose of creating an Android native extension for GameMaker projects (best-practice way).

Okay, so what i read from the YoYo official documentation about creating the native Android extension for GMS is:
the guide always reminds us of not forgeting to add these three lines :

package ${YYAndroidPackageName};

import ${YYAndroidPackageName}.R; <-- i want to specificly ask about this

import com.yoyogames.runner.RunnerJNILib;
CASE A:
I have an Android extension from the marketplace that is working fine when is running on the device
that it :
import ${YYAndroidPackageName}.R WITHOUT import ${YYAndroidPackageName}.RunnerActivity;
when the rest of the java codes on the middle area is calling RunnerActivity.something bla bla bla.

CASE B:
I also see another Android extension from the marketplace which is also working fine when is running on the device
that it :
import ${YYAndroidPackageName}.R AND ALSO WITH import ${YYAndroidPackageName}.RunnerActivity;
when the rest of the java codes on the middle area is calling RunnerActivity.something bla bla bla.

BOTH are working fine, so MY QUESTIONS as the title of this thread:
1. Is "R" shortcut of "RunnerActivity"??
~ import ${YYAndroidPackageName}.R; representing-or-shortcut of import ${YYAndroidPackageName}.RunnerActivity; ???

2. Is the CASE A or CASE B the same thing? which is the best practice to be implemented so that GMS2 Android mobile runner can recognize the code better?

3. If on the java codes for the Android extension to be used for GMS2 runner to work with best-practice way,
-- Do i need to import one of them already enough?
-- only import ${YYAndroidPackageName}.R ??
-- or just import ${YYAndroidPackageName}.RunnerActivity; ??
-- or both import ${YYAndroidPackageName}.R AND ALSO WITH import ${YYAndroidPackageName}.RunnerActivity; ??

note: i also learned that most Android extensions for GMS/GMS2 also import android.app.Activity; in addition to both that yellow and green. Out of my question but i want to hear some tips about it too, because is related to the Android Activity.
 
H

HW.

Guest
Ah okay, after google searching, i now understand the concept of the "import" in Java.
LOL, after understanding this, I smile reading my own questions :p
But it is okay! as there is no need to be ashamed.
I learned something today :D

So to answer my own questions here, that might also be useful for anyone else who is curious about this "R" and "import" like i was when i created this thread,
1. Is "R" shortcut of "RunnerActivity"??
~ import ${YYAndroidPackageName}.R; representing-or-shortcut of import ${YYAndroidPackageName}.RunnerActivity; ???
No, R is related to R.java. It is an auto-generated java file inside the package name of our Android package app.
source: https://www.quora.com/What-is-R-java-in-android

It is different with RunnerActivity.java which is the java file of GMS2's runtime, to be used when compiles the .apk i believe.
source: take a peek at my GMS2 program folder,
C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.1.4.212\android\runner\ProjectFiles\src\main\java\YYAndroidPackageDomain\YYAndroidPackageCompany\YYAndroidPackageProduct

2. Is the CASE A or CASE B the same thing? which is the best practice to be implemented so that GMS2 Android mobile runner can recognize the code better?
They are different things.
-- import ${YYAndroidPackageName}.R refers to R.java
-- import ${YYAndroidPackageName}.RunnerActivity; refers to RunnerActivity.java

But Both cases (A/B) can work fine, because the "import" in java is simply a "shorthand" way to reference one or more classes in a package.
And the import is "optional" or doesn't need if the classes are already in the same package location. The compiler understands it.
so that's why without importing "RunnerActivity", it can also work fine on case A, while it is calling RunnerActivity.something multiple times on the codes.

sources:
https://stackoverflow.com/questions/1053658/how-is-import-done-in-java
https://stackoverflow.com/questions/10194121/classes-in-same-package

3. If on the java codes for the Android extension to be used for GMS2 runner to work with best-practice way,
-- Do i need to import one of them already enough?
-- only import ${YYAndroidPackageName}.R ??
-- or just import ${YYAndroidPackageName}.RunnerActivity; ??
-- or both import ${YYAndroidPackageName}.R AND ALSO WITH import ${YYAndroidPackageName}.RunnerActivity; ??
up to you :p please read 1. 2.

So this is [SOLVED], i will edit the title:
Previous Title:
is---${YYAndroidPackageName}.R---representing/shortcut-of--"${YYAndroidPackageName}.RunnerActivity"?

become:
[SOLVED] import java extension ${YYAndroidPackageName}.R - ${YYAndroidPackageName.RunnerActivity

~
Thanks to Google for providing an outstanding search engine that helps so many people on this planet. o_O
Thanks to the people from stackoverflow, quora -- for providing the free Q/A sites, sharing knowledge for the world. ;)
Thanks to YoYo team for creating awesome GMS2 software with Android mobile modules! :cool:
Thanks to the GameMaker community on this forum i can learn many things by reading many threads or creating threads here :)
last but not least,
Thanks to you for reading this thread. (~Don't forget to like and subscribe my channel! ---LOLL just kidding, i am not a youtuber! :D)
 
Top