在libgdx游戏中添加"评价我的应用程序"按钮

Vis*_*ngh 14 android libgdx

我想在我的游戏中添加一个按钮,该按钮将在Play商店中打开我的应用程序的URL.下面是我到目前为止所得到的,但当我点击率按钮时,它不会打开相应的URL.

我的费率代码是:

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

Xia*_* Yu 37

您应该在Net模块中使用openURI方法.

就像是:

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

exec可能不是跨平台,至少不会在Android上运行.
不要重新发明轮子.

  • @BoldijarPaul您可能忘记在Android Manifest文件中提供Internet访问权限 (5认同)