2

Currently, I want to Open this link and if the application is not installed need it to navigate to 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;

I want it to launch to app store from this URL is it possible ?

Chinthaka Devinda
  • 997
  • 5
  • 16
  • 36

2 Answers2

3

To accomplish this, you would need to perform a javascript redirect. I would host a web page at any url you'd like i.e. yourdomain.com/checkForApp and have some simple redirects.

Try the link, if it fails use Javascript redirect to the play store or app store.

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.

clayjones94
  • 2,648
  • 17
  • 26
2
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);
}
Abdul Wahab
  • 819
  • 1
  • 7
  • 18