Author Topic: Android Vibration  (Read 194 times)

Offline MK2004

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Android Vibration
« on: 2019-Jan-10 »
Hallo,
I want use Vibration in my Android Game, is it possible to use the Vibration with JAVACall?
If this is possibel how should i do this?

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3576
    • View Profile
    • Space Fractal
Re: Android Vibration
« Reply #1 on: 2019-Jan-10 »
not official, just to been noted, you can currectly not release your game on Google Play, but you can release it on other stores. Im do cant remember on my head, because im is soon vaccation.

But all javacalls is been called to SDLActivity.Java, and if you have expirence with java, you can add it and remember to eventuelly add the permission in manifest as well.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline MK2004

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Re: Android Vibration
« Reply #2 on: 2019-Feb-07 »
Hallo,

I solved the Problem.


First edit the file "AndroidManifest.xml" in the directory
C:\Program Files (x86)\GLBasic\Compiler\platform\android\templateproj\
put in this to activate Vibration permission.
<uses-permission android:name="android.permission.VIBRATE"/>

I used Notepad++



Secondly edit the file "SDLActivity.java" in the directory
C:\Program Files (x86)\GLBasic\Compiler\platform\android\templateproj\src\com\glbasic\test\

I attach my file



Third my GLBasic Code

Code: GLBasic [Select]

?IFDEF ANDROID
        IMPORT "C" const char* android_JAVACALL(const char* string)
?ENDIF

// The mobile phone vibrates for 1000 milliseclaps
LOCAL v=CallJava$("vibriere:1000")

SLEEP 2000


        FUNCTION CallJava$: Args$
                LOCAL result$
                ?IFDEF ANDROID
                result$=android_JAVACALL(Args$)
                RETURN result$
                ?ENDIF
        ENDFUNCTION

 



Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1386
    • View Profile
Re: Android Vibration
« Reply #3 on: 2019-Feb-07 »
Guys
Just so you know I did recent update to game-killing bug I had to fix
I just updated the manifest to target api version "26" and uploaded the new version it worked fine - no increased crashes or anything.

I still have pre-api issue with the stuck background wake locks - which is high - and liinked to Audiomix
I am investigating trying to fix with a change I did SDLActivity.

So Google is still working for now using current compiler but using target of the higher api



Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3576
    • View Profile
    • Space Fractal
Re: Android Vibration
« Reply #4 on: 2019-Feb-07 »
this is nice to hear its still possible, even using the older SDK but with new API. Which kind of pre-api do you have?

Im should checking thing like that, so this is a workaround for now, until the next year 64bit requirements.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1386
    • View Profile
Re: Android Vibration
« Reply #5 on: 2019-Feb-08 »
Is this what you mean...

Android SDK Tools Revision 24.0.2
Using latest Build Tools: 21.1.2
API level:        22

Im also on an older GLB but that is because I am using AE 2.9  (only for the reason to make sure my adverts still work - I am using Google services

<meta-data android:name="com.google.android.gms.version"
              android:value="7895000"/>

Only issues I have are background wakelocks related to audiomix - but loads of other frameworks have posts about the same issue - it only appeared since Android 8.0 came along...and its a problem for everyone including Unity - not sure if someone fixed it yet.

 
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs