Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa guida descrive come integrare le recensioni in-app nella tua app utilizzando Kotlin o Java. Esistono guide all'integrazione separate se utilizzi codice
nativo, Unity o Unreal Engine.
Configura l'ambiente di sviluppo
La libreria per le recensioni in-app di Play fa parte delle librerie di base Google Play.
Includi la seguente dipendenza Gradle per integrare la libreria Play In-App Review.
Trendy
// In your app's build.gradle file:...dependencies{// This dependency is downloaded from the Google's Maven repository.// So, make sure you also include that repository in your project's build.gradle file.implementation'com.google.android.play:review:2.0.2'// For Kotlin users also add the Kotlin extensions library for Play In-App Review:implementation'com.google.android.play:review-ktx:2.0.2'...}
Kotlin
// In your app's build.gradle.kts file:...dependencies{// This dependency is downloaded from the Google's Maven repository.// So, make sure you also include that repository in your project's build.gradle file.implementation("com.google.android.play:review:2.0.2")// For Kotlin users also import the Kotlin extensions library for Play In-App Review:implementation("com.google.android.play:review-ktx:2.0.2")...}
Crea ReviewManager
L'ReviewManager è l'interfaccia che consente alla tua app di avviare un flusso di recensioni in-app. Ottienilo creando un'istanza utilizzando
ReviewManagerFactory.
Segui le indicazioni su quando richiedere recensioni in-app per determinare i punti
migliori nel flusso utente della tua app per chiedere all'utente di lasciare una recensione (ad esempio,
quando l'utente completa un livello in un gioco). Quando la tua app raggiunge uno di questi
punti, utilizza l'istanza ReviewManager per creare un'attività di richiesta. In caso di esito positivo, l'API restituisce l'oggetto ReviewInfo necessario per avviare il flusso di revisione in-app.
Kotlin
valrequest=manager.requestReviewFlow()request.addOnCompleteListener{task->if(task.isSuccessful){// We got the ReviewInfo objectvalreviewInfo=task.result}else{// There was some problem, log or handle the error code.@ReviewErrorCodevalreviewErrorCode=(task.getException()asReviewException).errorCode}}
Java
ReviewManagermanager=ReviewManagerFactory.create(this);Task<ReviewInfo>request=manager.requestReviewFlow();request.addOnCompleteListener(task->{if(task.isSuccessful()){// We can get the ReviewInfo objectReviewInforeviewInfo=task.getResult();}else{// There was some problem, log or handle the error code.@ReviewErrorCodeintreviewErrorCode=((ReviewException)task.getException()).getErrorCode();}});
Avviare il flusso di revisione in-app
Utilizza l'istanza ReviewInfo per avviare il flusso di revisione in-app. Attendi che
l'utente abbia completato il flusso di revisione in-app prima che la tua app continui il suo
normale flusso utente (ad esempio, il passaggio al livello successivo).
Kotlin
valflow=manager.launchReviewFlow(activity,reviewInfo)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.}
Java
Task<Void>flow=manager.launchReviewFlow(activity,reviewInfo);flow.addOnCompleteListener(task->{// 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.});
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-08-21 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-21 UTC."],[],[],null,["# Integrate in-app reviews (Kotlin or Java)\n\nThis guide describes how to integrate in-app reviews in your app using either\nKotlin or Java. There are separate integration guides if you are using [native\ncode](/guide/playcore/in-app-review/native), [Unity](/guide/playcore/in-app-review/unity) or [Unreal Engine](/guide/playcore/in-app-review/unreal-engine).\n\nSet up your development environment\n-----------------------------------\n\nThe Play In-App Review Library is a part of the [Google Play Core libraries](/guide/playcore).\nInclude the following Gradle dependency to integrate the Play In-App Review\nLibrary. \n\n### Groovy\n\n```groovy\n// In your app's build.gradle file:\n...\ndependencies {\n // This dependency is downloaded from the /studio/build/dependencies#google-maven.\n // So, make sure you also include that repository in your project's build.gradle file.\n implementation 'com.google.android.play:review:2.0.2'\n\n // For Kotlin users also add the Kotlin extensions library for Play In-App Review:\n implementation 'com.google.android.play:review-ktx:2.0.2'\n ...\n}\n```\n\n### Kotlin\n\n```kotlin\n// In your app's build.gradle.kts file:\n...\ndependencies {\n // This dependency is downloaded from the /studio/build/dependencies#google-maven.\n // So, make sure you also include that repository in your project's build.gradle file.\n implementation(\"com.google.android.play:review:2.0.2\")\n\n // For Kotlin users also import the Kotlin extensions library for Play In-App Review:\n implementation(\"com.google.android.play:review-ktx:2.0.2\")\n ...\n}\n```\n\nCreate the ReviewManager\n------------------------\n\nThe [`ReviewManager`](/reference/com/google/android/play/core/review/ReviewManager) is the interface that lets your app start an in-app\nreview flow. Obtain it by creating an instance using the\n[`ReviewManagerFactory`](/reference/com/google/android/play/core/review/ReviewManagerFactory). \n\n### Kotlin\n\n```kotlin\nval manager = ReviewManagerFactory.create(context)\n```\n\n### Java\n\n```java\nReviewManager manager = ReviewManagerFactory.create(context)\n```\n\nRequest a ReviewInfo object\n---------------------------\n\nFollow the guidance about [when to request in-app reviews](/guide/playcore/in-app-review#when-to-request) to determine good\npoints in your app's user flow to prompt the user for a review (for example,\nwhen the user completes a level in a game). When your app reaches one of these\npoints, use the [`ReviewManager`](/reference/com/google/android/play/core/review/ReviewManager) instance to create a request task. If\nsuccessful, the API returns the [`ReviewInfo`](/reference/com/google/android/play/core/review/ReviewInfo) object needed to start the\nin-app review flow. \n\n### Kotlin\n\n```kotlin\nval request = manager.requestReviewFlow()\nrequest.addOnCompleteListener { task -\u003e\n if (task.isSuccessful) {\n // We got the ReviewInfo object\n val reviewInfo = task.result\n } else {\n // There was some problem, log or handle the error code.\n @ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode\n }\n}\n```\n\n### Java\n\n```java\nReviewManager manager = ReviewManagerFactory.create(this);\nTask\u003cReviewInfo\u003e request = manager.requestReviewFlow();\nrequest.addOnCompleteListener(task -\u003e {\n if (task.isSuccessful()) {\n // We can get the ReviewInfo object\n ReviewInfo reviewInfo = task.getResult();\n } else {\n // There was some problem, log or handle the error code.\n @ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();\n }\n});\n```\n| **Note:** The [`ReviewInfo`](/reference/com/google/android/play/core/review/ReviewInfo) object is only valid for a limited amount of time. Your app should request a `ReviewInfo` object ahead of time (pre-cache) but only once you are certain that your app will launch the in-app review flow.\n\nLaunch the in-app review flow\n-----------------------------\n\nUse the [`ReviewInfo`](/reference/com/google/android/play/core/review/ReviewInfo) instance to launch the in-app review flow. Wait until\nthe user has completed the in-app review flow before your app continues its\nnormal user flow (such as advancing to the next level). \n\n### Kotlin\n\n```kotlin\nval flow = manager.launchReviewFlow(activity, reviewInfo)\nflow.addOnCompleteListener { _ -\u003e\n // The flow has finished. The API does not indicate whether the user\n // reviewed or not, or even whether the review dialog was shown. Thus, no\n // matter the result, we continue our app flow.\n}\n```\n\n### Java\n\n```java\nTask\u003cVoid\u003e flow = manager.launchReviewFlow(activity, reviewInfo);\nflow.addOnCompleteListener(task -\u003e {\n // The flow has finished. The API does not indicate whether the user\n // reviewed or not, or even whether the review dialog was shown. Thus, no\n // matter the result, we continue our app flow.\n});\n```\n| **Important:** If an error occurs during the in-app review flow, do not inform the user or change your app's normal user flow. Continue your app's normal user flow after `onComplete` is called.\n\nNext steps\n----------\n\n[Test your app's in-app review flow](/guide/playcore/in-app-review/test) to verify that your integration is\nworking correctly."]]