0

我已经实现了“评价我的应用程序”功能。但是我只想在用户单击按钮时才显示询问评分的警报exit

AppRater 的代码来自http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater

退出按钮上的代码:

case R.id.exit:
        Log.i(DEBUG_TAG, "Exiting from application");
        AppRater.app_launched(this);   //Display alert for app rating
        Intent exitIntent = new Intent(Intent.ACTION_MAIN);
        exitIntent.addCategory(Intent.CATEGORY_HOME);
        exitIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(exitIntent);
        this.finish();
        break;

现在使用此代码,它会在当前活动完成时显示警报一秒钟。

我只想在用户单击警报框中的任何按钮时完成当前活动。

4

2 回答 2

0

您可以为结果启动活动......而不是 startActivity() 方法,您可以使用 startActivityForResult()... 可能是这项工作...

于 2012-07-24T10:11:59.480 回答
0

Instead of Calling this.finish() immediately after you show the dialog box.

Call the same after any of the button is selected in the DialogBox shown.

As you are calling this.finish() the context is lost immediately so closing the dialog as well.

If you do this you do not need to have the below code in your app.

    Intent exitIntent = new Intent(Intent.ACTION_MAIN);
    exitIntent.addCategory(Intent.CATEGORY_HOME);
    exitIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(exitIntent);
    this.finish();
于 2012-07-24T10:12:31.777 回答