[英]Launch google play store if app is not installed
Currently, I want to Open this link and if the application is not installed need it to navigate to google play. 目前,我想打开此链接,如果未安装该应用程序,则需要它导航到Google Play。 Following is the link I am trying to open.
以下是我尝试打开的链接。
intent:qoo10sg://moveTab?index=2&url=https%3A%2F%2Fm.qoo10.my%2Fgmkt.inc%2FMobile%2FDeal%2FTimeSale.aspx%3Fcix%3D0%26__da_seqno%3D39213891#Intent;package=net.giosis.shopping.sg;end;
intent:qoo10sg:// moveTab?index = 2&url = https%3A%2F%2Fm.qoo10.my%2Fgmkt.inc%2FMobile%2FDeal%2FTimeSale.aspx%3Fcix%3D0%26__da_seqno%3D39213891#Intent; package = net。 giosis.shopping.sg; end;
I want it to launch to app store from this URL is it possible ? 我希望它可以从此URL启动到应用商店吗?
Use this 用这个
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)));
}
if (!openApp(MainActivity.this, "com.package")) {
launchPlayStoreWithAppPackage(MainActivity.this, "com.pagkage");
}
/**
* Open another app.
*
* @param context current Context, like Activity, App, or Service
* @param packageName the full package name of the app to open
* @return true if likely successful, false if unsuccessful
*/
public static boolean openApp(Context context, String packageName) {
PackageManager manager = context.getPackageManager();
try {
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
//throw new ActivityNotFoundException();
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(i);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
/**
* Open another app.
*
* @param context current Context, like Activity, App, or Service
* @param packageName the full package name of the app to open
*/
public static void launchPlayStoreWithAppPackage(Context context, String packageName) {
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
context.startActivity(i);
}
To accomplish this, you would need to perform a javascript redirect. 为此,您需要执行javascript重定向。 I would host a web page at any url you'd like ie
yourdomain.com/checkForApp
and have some simple redirects. 我会在您想要的任何URL上托管一个网页,即
yourdomain.com/checkForApp
并进行一些简单的重定向。
Try the link, if it fails use Javascript redirect to the play store or app store. 尝试链接,如果失败,请使用Javascript重定向到Play商店或应用商店。
setTimeout(function appNotInstalled() {
window.location.replace("http://play.google.com/store");
}, 100);
window.location.replace("intent:qoo10sg://moveTab?index=2&url=https%3A%2F%2Fm.qoo10.my%2Fgmkt.inc%2FMobile%2FDeal%2FTimeSale.aspx%3Fcix%3D0%26__da_seqno%3D39213891#Intent;package=net.giosis.shopping.sg;end;");
Otherwise, Branch does this already within their SDK so you don't have to worry about building this out. 否则, Branch已经在其SDK中进行了此操作,因此您不必担心会这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.