By using developer.andriod.com, one can solve this problem by using the market:// prefix.
For Java Users:-
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
For Kotlin Users
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
}
In using a catch/try block, the objective is for an Exception to be thrown if the Google Play Store is not installed on a target device.
Please NOTE: That any application can register and is capable of handling the
market://details?id=<appId> Uri,