When your app becomes live in PlayStore, You want more audience to download and use your app. Mostly they will look at your rating stars and review their comments which means the app rating and review become important in gain audience and downloads to your app.
Traditionally we have to implement some code in your app to redirect users into Google Playstore so that they can review your app. To improve more user-friendly, we encourage users to review or rate the app through a popup dialog Google Provide an API called in-App Review which displays the rating popup within the app itself, so the users are more likely to rate the app.
Step 1: Create a new project in Android Studio (File -> New -> Project -> Select Empty Activty -> Name project AppReviewTest -> Finish)
Step 2: Insert the Google Play Core Dependency to android build.gradle file (Module: app). Note: My latest play core version (video) was 1.10.3 but you can use the latest stable release you want from Play Core Library. (app -> build.gradle(Module: app))
implementation 'com.google.android.play:core:1.10.0'
Step 3: In this example, we will add a button to show the dialog review, but in case you apply in real project should not apply like this. Open the following to edit the layout (app -> res -> layout -> activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn"
android:text="Show"/>
</LinearLayout>
Step 4: Implement Java code in MainActivity.java. Open file the following (app -> java -> MainActivity.java)
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.play.core.review.ReviewInfo;
import com.google.android.play.core.review.ReviewManager;
import com.google.android.play.core.review.ReviewManagerFactory;
import com.google.android.play.core.tasks.Task;
public class MainActivity extends AppCompatActivity {
private ReviewInfo reviewInfo;
private ReviewManager manager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activateReviewInfo();
Button btn = findViewById(R.id.btn);
btn.setOnClickListener((view)->
{
startReviewFlow();
});
}
void activateReviewInfo()
{
manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> managerInfoTask = manager.requestReviewFlow();
managerInfoTask.addOnCompleteListener((task)->
{
if(task.isSuccessful())
{
reviewInfo = task.getResult();
}
else
{
Toast.makeText(this, "Review failed to start", Toast.LENGTH_SHORT).show();
}
});
}
void startReviewFlow()
{
if(reviewInfo !=null)
{
Task<Void> flow= manager.launchReviewFlow(this,reviewInfo);
flow.addOnCompleteListener(task ->
{
Toast.makeText(this, "Rating is completed", Toast.LENGTH_SHORT).show();
});
}
}
}
To test the in-app review flow, you should have the app approved already live on PlayStore.
This doesn’t mean the app should be available to the public. You may add the app for Internal Testing or Internal App Sharing. To more understanding please check the video above to see all processes.
You might Also Like:
As the founder and passionate educator behind this platform, I’m dedicated to sharing practical knowledge in programming to help you grow. Whether you’re a beginner exploring Machine Learning, PHP, Laravel, Python, Java, or Android Development, you’ll find tutorials here that are simple, accessible, and easy to understand. My mission is to make learning enjoyable and effective for everyone. Dive in, start learning, and don’t forget to follow along for more tips and insights!. Follow him