val uri = Uri.parse("market://details?id=" + BuildConfig.APPLICATION_ID)var intent = Intent(Intent.ACTION_VIEW, uri)// To count with Play market backstack, After pressing back button,// to taken back to our application, we need to add following flags to intent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)if (intent.resolveActivity(activity.packageManager) != null) { startActivity(intent)}else { intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID)) if (intent.resolveActivity(activity.packageManager) != null) { startActivity(intent) } else { Toast.makeText(activity, "No play store or browser app", Toast.LENGTH_LONG).show() }}
❤️ Is this article helpful?
Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.
Do send some 💖 to @d_luaz or share this article.
✨ By Desmond Lua
A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz
👶 Apps I built
Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.