Open play store app from browser link
I got it working by using the below url on redirect
window.location.href = "https://play.app.goo.gl/?link=https://play.google.com/store/apps/details?id=com.myapp";
When I visit this url from the browser of my mobile, it does not open the play store within browser but opens the play store app instead. This serves my purpose.
How to make a web link open directly on Google Play Store
As explained here, Google Play provides url protocol
market://details?id=<package_name>
Applying on Blogger :
Place the following javascript code at the bottom and before </body>
. This will change Google Play links only on Android.
<script>
if (/(android)/i.test(navigator.userAgent)) {
document.querySelectorAll('a[href]').forEach(function (link) {
link.href = link.href.replace('https://play.google.com/store/apps/','market://');
});
}
</script>
open google play store link of App if a user wants to open website in android phone
You don't need to do anything special. When you click on a link to the Play Store from any browser on an Android phone, the Market app will handle the link automatically.
For example, try clicking this link on your Android device:
http://play.google.com/store/apps/details?id=com.google.android.apps.maps
If the Market app is installed, it will automatically open the page to install the application.
There are lots of resources for detecting an Android user-agent and redirecting. For example http://davidwalsh.name/detect-android
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
// Do something!
// Redirect to Android-site?
window.location = 'http://play.google.com/store/apps/details?id=com.google.android.apps.maps';
}
How to open the Google Play Store directly from my Android application?
You can do this using the market://
prefix.
Java
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)));
}
Kotlin
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")))
}
We use a try/catch
block here because an Exception
will be thrown if the Play Store is not installed on the target device.
NOTE: any app can register as capable of handling the market://details?id=<appId>
Uri, if you want to specifically target Google Play check the Berťák answer
Is any right approch to open direct google play store after click button in android
This solution is worked fine for me .
fun shareApp(appPackageName: String, activity: Activity){
try {
startActivity(Intent(
Intent.ACTION_VIEW,
Uri.parse("market://details?id=$appPackageName")
))
} catch (e : ActivityNotFoundException) {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")
)
)
}
}
So here we use two things if any devices specific app store available then it open it and otherwise it open play store directly . and showing your app.
Whenever i click on button then it showing me choice for select market app or play store , when i click on play store then it open and show related app.
I hope this help you..
Related Topics
Imageview of Png Doesn't Appear (Maybe It's Too Big)
Control the Playback Speed of Video in Android
How to Figure Out Which Sim Received Sms in Dual Sim Android Device
App Restarts Rather Than Resumes
How to Use Adb With Emulator Like Memu/Bluestacks/Nox App Player
Clear Cache in Android Application Programmatically
Retrofit Body Giving Null Values But Coming Perfect in Postman
How to Kill Native Applications from 'Adb Shell'
R Cannot Be Resolved - Android Error
How to Set Spinner Default by Its Value Instead of Position
How to Verify Purchase for Android App in Server Side (Google Play in App Billing V3)
How to Detect When the App Goes to Minimized or Exit
How to Connect Existing Android Studio Project to Existing Github Repository
Android:Get Current Date and Time from Firebase
How to Stop Refreshing Recyclerview Data Scroll to Top Position Android Everytime
Android - Edittext Not Showing Any Text
How to Add the Json Response into Spinner in Android Using Retrofit