love2d / love-android

Android build setup for LÖVE.
https://love2d.org
Other
211 stars 73 forks source link

GameActivity vs other Activities #209

Closed castelo3442 closed 3 years ago

castelo3442 commented 3 years ago

I`m trying to implement in-app purchases on Android Studio. Can I create a button in the GameActivity using Android Studio, so it would appear while my app is "running" in the background? Or is it possible to use another Activity after love-android compilation? So far, I can setup the billingClient, PurchasesUpdatedListener, start the connection, and query skus, but when I try to use a button in the java/xml files to start the "billing flow", the game crashes. Maybe I'm just doing it wrong, but maybe there is a very specific way to do it while running the .love file. Any suggestion?

MikuAuahDark commented 3 years ago

Not sure about the former but yes you can do the latter. You just have to change these lines to your fully qualified activity name that derives from LOVE's GameActivity.

https://github.com/love2d/love-android/blob/89c9fc0a70345ebf39807c17d627807a02591bdb/app/src/main/AndroidManifest.xml#L33 https://github.com/love2d/love-android/blob/89c9fc0a70345ebf39807c17d627807a02591bdb/app/src/embed/AndroidManifest.xml#L18

castelo3442 commented 3 years ago

Ive figured out how to create the button in GameActivity, so I believe I dont need to change it in the Android Manifest. But once a call setContentView(R.layout.activity_game) for the button to work; I cant come back to the regular app screen after the button is clicked in "OnClick ()". (A) How do I do it, onceI find no layout? Or, if its not the best way, and I must do it in 2 different Activities, (B) how do I call the gameActivity back? Will it not start the game from the beginning? Would I use the billing activity as the main one?

MikuAuahDark commented 3 years ago

I'm not quite sure about that. Your way is probably interfere with SDL however so I can't say anything about it.

castelo3442 commented 3 years ago

When running in Android, can I pick and read/write a variable that is inside the .love file, or in a shared save file?

MikuAuahDark commented 3 years ago

Does https://github.com/bartbes/jniwrap work for you?

castelo3442 commented 3 years ago

Thanks!!!