如何实现在Android应用程序给它打分功能给它、如何实现、应用程序、功能

2023-09-03 21:06:12 作者:求岳母发货

我开发一个Android应用程序。在这一切工作的权利。我的应用程序是准备发射。但是,我需要实现一个特性。我需要显示一个弹出包含

I am developing an Android App. In which everything is working right. My app is ready to launch. But there I need to implement one more feature. I need to display a popup which contains

给它打分以后提醒我

下面,如果任何用户速率在市场上的应用程序,然后在弹出不会消失。 我已经搜索谷歌和发现了一个链接。有了这个,我明白,它不可能知道。所以我需要一个建议这一点。

Here if any user rate the app in market then the popup won't be disappeared. I have searched in Google and found one link. With this i understand that its not possible to know. so i need a suggestion for this.

任何机构之前遇到过这种情况。如果是的话有没有什么解决办法或任何替代这一点。

Can any body face this situation before. if so is there any solution or any alternative for this.

请帮助我。在此先感谢。

please help me. Thanks in Advance.

推荐答案

我实现了这个而回,在一定程度上。这是不可能知道用户是否已经评价一个应用程序,以prevent收视率成为货币(有些开发商可能会添加一个选项,如评价此应用程序,并能获得,因此,在免费应用程序)。

I implemented this a while back, to some extent. It is impossible to know whether or not a user has rated an app, to prevent ratings from becoming a currency (some developers might add an option like "Rate this app and get so and so in the app for free").

我写了这个类提供了三个按钮,并配置对话框,使其后的应用程序已经启动 N 时间才会显示(用户有评级较高的机会如果他们已经有点之前使用它的应用程序,他们大多是不太可能甚至不知道它在第一次运行):

The class I wrote provides three buttons, and configures the dialog so that it is only shown after the app has been launched n times (users have a higher chance of rating the app if they've used it a bit before. Most of them are unlikely to even know what it does on the first run):

public class AppRater {
    private final static String APP_TITLE = "App Name";// App Name
    private final static String APP_PNAME = "com.example.name";// Package Name

    private final static int DAYS_UNTIL_PROMPT = 3;//Min number of days
    private final static int LAUNCHES_UNTIL_PROMPT = 3;//Min number of launches

    public static void app_launched(Context mContext) {
        SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
        if (prefs.getBoolean("dontshowagain", false)) { return ; }

        SharedPreferences.Editor editor = prefs.edit();

        // Increment launch counter
        long launch_count = prefs.getLong("launch_count", 0) + 1;
        editor.putLong("launch_count", launch_count);

        // Get date of first launch
        Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0);
        if (date_firstLaunch == 0) {
            date_firstLaunch = System.currentTimeMillis();
            editor.putLong("date_firstlaunch", date_firstLaunch);
        }

        // Wait at least n days before opening
        if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
            if (System.currentTimeMillis() >= date_firstLaunch + 
                    (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
                showRateDialog(mContext, editor);
            }
        }

        editor.commit();
    }   

    public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
        final Dialog dialog = new Dialog(mContext);
        dialog.setTitle("Rate " + APP_TITLE);

        LinearLayout ll = new LinearLayout(mContext);
        ll.setOrientation(LinearLayout.VERTICAL);

        TextView tv = new TextView(mContext);
        tv.setText("If you enjoy using " + APP_TITLE + ", please take a moment to rate it. Thanks for your support!");
        tv.setWidth(240);
        tv.setPadding(4, 0, 4, 10);
        ll.addView(tv);

        Button b1 = new Button(mContext);
        b1.setText("Rate " + APP_TITLE);
        b1.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));
                dialog.dismiss();
            }
        });        
        ll.addView(b1);

        Button b2 = new Button(mContext);
        b2.setText("Remind me later");
        b2.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        ll.addView(b2);

        Button b3 = new Button(mContext);
        b3.setText("No, thanks");
        b3.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (editor != null) {
                    editor.putBoolean("dontshowagain", true);
                    editor.commit();
                }
                dialog.dismiss();
            }
        });
        ll.addView(b3);

        dialog.setContentView(ll);        
        dialog.show();        
    }
}

整合类很简单,只要加入:

Integrating the class is as simple as adding:

AppRater.app_launched(this);

要你的活动。它只需要加入到1个活动在整个应用程序。

To your Activity. It only needs to be added to one Activity in the entire app.