Write a review to any Android application user has to go GooglePlay and there they has to select app and write a review for the application.
Due to this lenthy process user might not interest on writing a review for the app.
This post will teach you how to integrate GooglePlay Inapp review API in Android
Let's get started
Step 1: Create an Android application in Android studio
Step 2: Add Inapp Review dependencies in build.gradle file
implementation 'com.google.android.play:core-ktx:1.8.1'
|
Step 3: To work with API we need to create an instance of ReviewManager class
Create RequestInfo Object
val request = manager.requestReviewFlow() |
Launch InApp Review Window
val flow = manager.launchReviewFlow(activity, reviewInfo) |
Step 4: Add Internet permission in manifest file
<uses-permission android:name="android.permission.INTERNET"/>
|
Step 5: To Test the InApp Review API App should be publish in GooglePlay.
What i did for this is
Minimum requirements
Design guidelines & Quota restrictions
Complete code
package com.rrtutors.inappreview
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.android.play.core.review.ReviewInfo
import com.google.android.play.core.review.ReviewManagerFactory
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
fun rateus(view: View) {
val manager = ReviewManagerFactory.create(applicationContext)
val request = manager.requestReviewFlow()
var reviewInfo: ReviewInfo? = null
request.addOnCompleteListener { request ->
if (request.isSuccessful) {
// We got the ReviewInfo object
reviewInfo = request.result
val flow = manager.launchReviewFlow(MainActivity@this, request.result)
flow.addOnCompleteListener { _ ->
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
}
} else {
// There was some problem, continue regardless of the result.
}
}
}
}
|
Android ViewModel Interview Questions
Article Contributed By :
|
|
|
|
1595 Views |