Implementing “Rate This App” Feature

If you have already published your app into android market, you might want to get a feedback from your users. This can be done in Google Play where users can rate an app and leave a comment. It will help you as a developer to improve your app and allows other users to see if your app is worth installing or not. Also, it might improve the criteria or your app on search result pages of Google Play.

To get more user rating and feeding the best way is to add a “Rate this app” button in your app. To proceed on this first thing you will need is your id in Google Play. To find out the id search your app in Google Play and check the url.

For example:


If this is the URL of your app, then the id is com.supercell.hayda. Note this id because we will need it in our code.(example url courtesy supercell) Now let’s start with the code to implement rate this app feature. Follow the steps below:

Step1: Create a new Android project in your android IDE.

Step2: Get the ID of your app from android market or google play.

Step3: Write following into your main layout file:

<RelativeLayout xmlns:android=""
xmlns:tools="" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:id="@+id/textView" />

android:text="Rate This App"
android:layout_marginTop="108dp" />


Step4: Write following into your main activity file:

package com.example.ratethisapp;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

Button btnRate = (Button) findViewById(;
btnRate.setOnClickListener(new View.OnClickListener(){

public void onClick(View v) {

private boolean isActivityStarted(Intent aIntent) {
return true;
catch (ActivityNotFoundException e)
return false;

public void onClickRateThisApp(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
if (!isActivityStarted(intent)) {
if (!isActivityStarted(intent)) {
Toast.makeText(this, "Could not open Android market, please check if the market app installed or not. Try again later", Toast.LENGTH_SHORT).show();
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == {
return true;

return super.onOptionsItemSelected(item);


Step5: Run for the output:




Checkout my previous blog on Camera Overlay Preview

Leave a Comment: