Last active
August 9, 2020 17:34
-
-
Save ahmed-shehataa/a4c72234a0fb164a5183d551111ace61 to your computer and use it in GitHub Desktop.
Revisions
-
ahmed-shehataa renamed this gist
Aug 9, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ahmed-shehataa created this gist
Aug 9, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ fun Activity.reviewAppDialog() { val manager = ReviewManagerFactory.create(this) (manager.requestReviewFlow()).addOnCompleteListener { request -> if (request.isSuccessful) { // We got the ReviewInfo object val reviewInfo = request.result manager.launchReviewFlow(this, reviewInfo) } else { // here ypu can call a normal review (send intent to google play or a browser) rateApp() } } } fun Activity.rateApp() { try { val sendIntent = Intent().apply { action = Intent.ACTION_SEND putExtra( Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName") ) } startActivity(sendIntent) } catch (e: ActivityNotFoundException) { startActivity( Intent( Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName") ) ) } }