Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a "rate my app" button in libgdx game

Tags:

android

libgdx

I want add a button in my game that will open up an URL to my app in Play Store. Below is what I got so far, but when I click on rate button it does not open the respective URL.

My rate code is:

if(Gdx.input.justTouched()){
    guiCam.unproject(touchPoint.set(Gdx.input.getX(),Gdx.input.getY(), 0));

    if(OverlapTester.pointInRectangle(rateButtonBound, touchPoint.x, touchPoint.y)){
        try {
            Process p = Runtime.getRuntime().exec("cmd /c start https://play.google.com/store/apps/details?id=com.shagunstudios.racinggame");
        }
        catch (IOException e1) {
            System.out.println(e1);
        }

        if(Settings.soundEnabled)
            Assets.click_sound.play(1.0f);

        return;
    }
}
like image 799
Vishal Singh Avatar asked Jul 05 '13 14:07

Vishal Singh


1 Answers

You should really be using openURI method in the Net module.

Something like:

Gdx.net.openURI("https://play.google.com/store/apps/details?id=com.shagunstudios.racinggame");

exec is probably not cross platform and will not work on Android at the least.
Don't re-invent the wheel.

like image 170
XiaoChuan Yu Avatar answered Sep 30 '22 17:09

XiaoChuan Yu