目前,我想打开此链接,如果未安装该应用程序,则需要将其导航到Google Play。以下是我试图打开的链接。
意图:qoo10sg:// moveTab索引= 2及URL = HTTPS%3A%2F%2Fm.qoo10.my%2Fgmkt.inc%2FMobile%2FDeal%2FTimeSale.aspx%3Fcix%3D0%26__da_seqno%3D39213891#意图;包= net.giosis.shopping.sg; END;
我希望它可以通过此URL启动到应用商店吗?
答案 0 :(得分:0)
使用此
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)));
}
答案 1 :(得分:0)
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);
}
答案 2 :(得分:0)
要实现此目的,您需要执行javascript重定向。我会在你想要的任何网址(即yourdomain.com/checkForApp
)上托管一个网页,并有一些简单的重定向。
尝试使用链接,如果失败则使用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;");
否则,Branch已在其SDK中执行此操作,因此您不必担心构建此问题。