ACluelessProgramer
ACluelessProgramer

Reputation: 308

Having a button that goes to give a review to my app?

I was wondering how I could implement having a button in my app that is linked to my Google Play app page in order to encourage people to give reviews for my app. If someone can answer me I would greatly appreciate it. I'm using Android Studio. Thanks.

Upvotes: 2

Views: 1306

Answers (2)

Mike
Mike

Reputation: 4570

Pretty easy, you can look up for your app in the store by your package name(the package name makes an application unique)

button.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" +getApplicationContext().getPackageName())));
        }
    }
);

Upvotes: 1

Elltz
Elltz

Reputation: 10859

with your button setting onclick listeners and all that put this code in it

Button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                final String myappPackageName = getPackageName(); // getPackageName() from Context or Activity object
                try {
                 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + myappPackageName)));
                } catch (android.content.ActivityNotFoundException anfe) {
                 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + myappPackageName)));
            }
        });

the catch helps prevent exception if user doesn't have google play installed.. hope it helps

Upvotes: 3

Related Questions