Reputation: 308
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
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
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