0

I am trying to open an android application using URL's, app was working fine previously and on all other devices, but its not working for samsung galaxy tab 10".

Heres My Code:

<intent-filter>
    <data
    android:host="com.magzine.nu"
    android:scheme="magzine" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

and using this "magzine://com.magzine.nu/?magid=532&issueid=7474" url to open the application, but when click on the URL a blank screen appears and disappears, not opening the application, any suggestion will be appreciated. Thanks in advance.

2 Answers 2

1

Actually Google did deprecate that function since Google Chrome version 25

Other way to do it you can use Android Intents like this in your url :

<a href="intent://read/#Intent;scheme=magzine;package=com.magzine.nu;end"> Will open magzine app</a>

and then set the manifest like this

  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="magzine" android:host="read" android:path="/"/>
  </intent-filter>

For more complete reference you can take a look at Zxing manifest (which is recommended by Google)

And then for parsing part you can take a look at Intent Source Code

especially this part :

/**
 * Convert this Intent into a String holding a URI representation of it.
 * The returned URI string has been properly URI encoded, so it can be
 * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
 * Intent's data as the base URI, with an additional fragment describing
 * the action, categories, type, flags, package, component, and extras.
 *
 * <p>You can convert the returned string back to an Intent with
 * {@link #getIntent}.
 *
 * @param flags Additional operating flags.  Either 0 or
 * {@link #URI_INTENT_SCHEME}.
 *
 * @return Returns a URI encoding URI string describing the entire contents
 * of the Intent.
 */
public String toUri(int flags) {
    StringBuilder uri = new StringBuilder(128);
    String scheme = null;
    if (mData != null) {
        String data = mData.toString();
        if ((flags&URI_INTENT_SCHEME) != 0) {
            final int N = data.length();
            for (int i=0; i<N; i++) {
                char c = data.charAt(i);
                if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
                        || c == '.' || c == '-') {
                    continue;
                }
                if (c == ':' && i > 0) {
                    // Valid scheme.
                    scheme = data.substring(0, i);
                    uri.append("intent:");
                    data = data.substring(i+1);
                    break;
                }

                // No scheme.
                break;
            }
        }
        uri.append(data);

    } else if ((flags&URI_INTENT_SCHEME) != 0) {
        uri.append("intent:");
    }

    uri.append("#Intent;");

    toUriInner(uri, scheme, flags);
    if (mSelector != null) {
        uri.append("SEL;");
        // Note that for now we are not going to try to handle the
        // data part; not clear how to represent this as a URI, and
        // not much utility in it.
        mSelector.toUriInner(uri, null, flags);
    }

    uri.append("end");

    return uri.toString();
}
Sign up to request clarification or add additional context in comments.

3 Comments

If this is the problem is with chrome updation then this should works with device browser, right ?
@arslanhaktic I don't think it'll affect the device browser too, but to be honest to use scheme like that is not the best way to open your app. Because you don't own that scheme anyone can use that and there is a security risk there too.
can you please refer some proper documentation/tutorial explain the best way to use this. Also i want to send parameters as well.
0

In my case, there was a code written to opens the app from background each time, That was causing the application to close as soon as it opens, and gives an impression that app is not getting open. After removing that code it works fine. So above code works perfect for my case. Also method mentioned by @NikoYuwono is more recommendable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.