Android Studio Deep Link using URI












0















Like the dozen other threads out there, I am trying to debug directly on a device using Android Studio via a uri. But I can't seem to find an exact example of someone doing so from Android Studio using the Edit Configuration. Sure something simple I am missing...



Here is what I am doing:




  1. Add the uri to the Edit Configuration:


enter image description here





  1. Here is the intent in the AndroidManifest.xml:



        <activity
    android:name="com.mayapp.StartActivity"
    android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
    android:label="StartActivity"
    android:launchMode="singleTask"
    android:windowSoftInputMode="stateHidden" >
    <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=myapp" />
    </intent-filter>
    </activity>


  2. The following error shows up when I try to debug:



enter image description here



As Text:



     11/21 13:15:05: Launching MyApp
Launching deeplink: myapp%3A%2F%2Fdispatch.

$ adb shell setprop log.tag.AppIndexApi VERBOSE
$ adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
Error while executing: am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch }
Error: Activity not started, unable to resolve Intent act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch flg=0x10000000

Error while Launching URL









share|improve this question



























    0















    Like the dozen other threads out there, I am trying to debug directly on a device using Android Studio via a uri. But I can't seem to find an exact example of someone doing so from Android Studio using the Edit Configuration. Sure something simple I am missing...



    Here is what I am doing:




    1. Add the uri to the Edit Configuration:


    enter image description here





    1. Here is the intent in the AndroidManifest.xml:



          <activity
      android:name="com.mayapp.StartActivity"
      android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
      android:label="StartActivity"
      android:launchMode="singleTask"
      android:windowSoftInputMode="stateHidden" >
      <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=myapp" />
      </intent-filter>
      </activity>


    2. The following error shows up when I try to debug:



    enter image description here



    As Text:



         11/21 13:15:05: Launching MyApp
    Launching deeplink: myapp%3A%2F%2Fdispatch.

    $ adb shell setprop log.tag.AppIndexApi VERBOSE
    $ adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
    Error while executing: am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
    Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch }
    Error: Activity not started, unable to resolve Intent act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch flg=0x10000000

    Error while Launching URL









    share|improve this question

























      0












      0








      0








      Like the dozen other threads out there, I am trying to debug directly on a device using Android Studio via a uri. But I can't seem to find an exact example of someone doing so from Android Studio using the Edit Configuration. Sure something simple I am missing...



      Here is what I am doing:




      1. Add the uri to the Edit Configuration:


      enter image description here





      1. Here is the intent in the AndroidManifest.xml:



            <activity
        android:name="com.mayapp.StartActivity"
        android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
        android:label="StartActivity"
        android:launchMode="singleTask"
        android:windowSoftInputMode="stateHidden" >
        <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=myapp" />
        </intent-filter>
        </activity>


      2. The following error shows up when I try to debug:



      enter image description here



      As Text:



           11/21 13:15:05: Launching MyApp
      Launching deeplink: myapp%3A%2F%2Fdispatch.

      $ adb shell setprop log.tag.AppIndexApi VERBOSE
      $ adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
      Error while executing: am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
      Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch }
      Error: Activity not started, unable to resolve Intent act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch flg=0x10000000

      Error while Launching URL









      share|improve this question














      Like the dozen other threads out there, I am trying to debug directly on a device using Android Studio via a uri. But I can't seem to find an exact example of someone doing so from Android Studio using the Edit Configuration. Sure something simple I am missing...



      Here is what I am doing:




      1. Add the uri to the Edit Configuration:


      enter image description here





      1. Here is the intent in the AndroidManifest.xml:



            <activity
        android:name="com.mayapp.StartActivity"
        android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
        android:label="StartActivity"
        android:launchMode="singleTask"
        android:windowSoftInputMode="stateHidden" >
        <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=myapp" />
        </intent-filter>
        </activity>


      2. The following error shows up when I try to debug:



      enter image description here



      As Text:



           11/21 13:15:05: Launching MyApp
      Launching deeplink: myapp%3A%2F%2Fdispatch.

      $ adb shell setprop log.tag.AppIndexApi VERBOSE
      $ adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
      Error while executing: am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d myapp%3A%2F%2Fdispatch -D
      Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch }
      Error: Activity not started, unable to resolve Intent act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=myapp://dispatch flg=0x10000000

      Error while Launching URL






      android android-studio deep-linking






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 21:50









      Stephen McCormickStephen McCormick

      771826




      771826
























          1 Answer
          1






          active

          oldest

          votes


















          0














          So, it would seem that there are several problems to what I was doing. What is interesting is that the way the AndroidManifest.xml was configured some 4 years ago seemed to be working, but to run in Android Studio not only does the scheme need to be specified but also the home in the Intent. In my case I have several actions associated with the same scheme, so the answer was to have multiple data sections within the same intent. I could not find any Android documentation on that, but I could have just missed it. So for anyone who might encounter this in the future here is what I did:





          1. In the AndroidManifest.XML define the intent just like I did, but make sure there is a home also. Obviously what you want the app to do when it does open can be different, seems to be a lot of info on that around so I am not including it here. For each action you want to trigger off of, add a new data section:



              <activity
            android:name="com.myapp.StartActivity"
            android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
            android:label="StartActivity"
            android:launchMode="singleTask"
            android:windowSoftInputMode="stateHidden" >
            <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="myapp" android:host="anondispatch"/>
            <data android:scheme="myapp" android:host="dispatch"/>
            <data android:scheme="myapp" android:host="openform"/>
            <data android:scheme="myapp" android:host="opendispatch"/>
            </intent-filter>
            </activity>



          2. In the code you can catch the opening in the onIntent() method in the specified activity (in my example it is StartActivity). Here is a sample of the code parsing out the elements you are looking for:



            protected void onNewIntent(Intent intent) {
            super.onNewIntent(intent);
            setIntent(intent);
            Intent intent = getIntent();
            if (intent.getAction() != null) {
            if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            Uri uri = intent.getData();
            String host = uri.getHost(); `
            String uriStr = uri.toString();
            if (host.equalsIgnoreCase("anondispatch")) {
            // parse out that you want
            }
            else if (host.equalsIgnoreCase("opendispatch")) {
            // parse out that you want
            }
            else if (host.equalsIgnoreCase("openform")) {
            // parse out that you want
            }
            else if (host.equalsIgnoreCase("dispatch)) {
            // parse out that you want
            }
            }
            }
            }
            }



          3. Update the configuration, from the Edit Configuration so the debugger can run on a remote device via USB by using the following:



          enter image description here






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420951%2fandroid-studio-deep-link-using-uri%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            So, it would seem that there are several problems to what I was doing. What is interesting is that the way the AndroidManifest.xml was configured some 4 years ago seemed to be working, but to run in Android Studio not only does the scheme need to be specified but also the home in the Intent. In my case I have several actions associated with the same scheme, so the answer was to have multiple data sections within the same intent. I could not find any Android documentation on that, but I could have just missed it. So for anyone who might encounter this in the future here is what I did:





            1. In the AndroidManifest.XML define the intent just like I did, but make sure there is a home also. Obviously what you want the app to do when it does open can be different, seems to be a lot of info on that around so I am not including it here. For each action you want to trigger off of, add a new data section:



                <activity
              android:name="com.myapp.StartActivity"
              android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
              android:label="StartActivity"
              android:launchMode="singleTask"
              android:windowSoftInputMode="stateHidden" >
              <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="myapp" android:host="anondispatch"/>
              <data android:scheme="myapp" android:host="dispatch"/>
              <data android:scheme="myapp" android:host="openform"/>
              <data android:scheme="myapp" android:host="opendispatch"/>
              </intent-filter>
              </activity>



            2. In the code you can catch the opening in the onIntent() method in the specified activity (in my example it is StartActivity). Here is a sample of the code parsing out the elements you are looking for:



              protected void onNewIntent(Intent intent) {
              super.onNewIntent(intent);
              setIntent(intent);
              Intent intent = getIntent();
              if (intent.getAction() != null) {
              if (Intent.ACTION_VIEW.equals(intent.getAction())) {
              Uri uri = intent.getData();
              String host = uri.getHost(); `
              String uriStr = uri.toString();
              if (host.equalsIgnoreCase("anondispatch")) {
              // parse out that you want
              }
              else if (host.equalsIgnoreCase("opendispatch")) {
              // parse out that you want
              }
              else if (host.equalsIgnoreCase("openform")) {
              // parse out that you want
              }
              else if (host.equalsIgnoreCase("dispatch)) {
              // parse out that you want
              }
              }
              }
              }
              }



            3. Update the configuration, from the Edit Configuration so the debugger can run on a remote device via USB by using the following:



            enter image description here






            share|improve this answer




























              0














              So, it would seem that there are several problems to what I was doing. What is interesting is that the way the AndroidManifest.xml was configured some 4 years ago seemed to be working, but to run in Android Studio not only does the scheme need to be specified but also the home in the Intent. In my case I have several actions associated with the same scheme, so the answer was to have multiple data sections within the same intent. I could not find any Android documentation on that, but I could have just missed it. So for anyone who might encounter this in the future here is what I did:





              1. In the AndroidManifest.XML define the intent just like I did, but make sure there is a home also. Obviously what you want the app to do when it does open can be different, seems to be a lot of info on that around so I am not including it here. For each action you want to trigger off of, add a new data section:



                  <activity
                android:name="com.myapp.StartActivity"
                android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
                android:label="StartActivity"
                android:launchMode="singleTask"
                android:windowSoftInputMode="stateHidden" >
                <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="myapp" android:host="anondispatch"/>
                <data android:scheme="myapp" android:host="dispatch"/>
                <data android:scheme="myapp" android:host="openform"/>
                <data android:scheme="myapp" android:host="opendispatch"/>
                </intent-filter>
                </activity>



              2. In the code you can catch the opening in the onIntent() method in the specified activity (in my example it is StartActivity). Here is a sample of the code parsing out the elements you are looking for:



                protected void onNewIntent(Intent intent) {
                super.onNewIntent(intent);
                setIntent(intent);
                Intent intent = getIntent();
                if (intent.getAction() != null) {
                if (Intent.ACTION_VIEW.equals(intent.getAction())) {
                Uri uri = intent.getData();
                String host = uri.getHost(); `
                String uriStr = uri.toString();
                if (host.equalsIgnoreCase("anondispatch")) {
                // parse out that you want
                }
                else if (host.equalsIgnoreCase("opendispatch")) {
                // parse out that you want
                }
                else if (host.equalsIgnoreCase("openform")) {
                // parse out that you want
                }
                else if (host.equalsIgnoreCase("dispatch)) {
                // parse out that you want
                }
                }
                }
                }
                }



              3. Update the configuration, from the Edit Configuration so the debugger can run on a remote device via USB by using the following:



              enter image description here






              share|improve this answer


























                0












                0








                0







                So, it would seem that there are several problems to what I was doing. What is interesting is that the way the AndroidManifest.xml was configured some 4 years ago seemed to be working, but to run in Android Studio not only does the scheme need to be specified but also the home in the Intent. In my case I have several actions associated with the same scheme, so the answer was to have multiple data sections within the same intent. I could not find any Android documentation on that, but I could have just missed it. So for anyone who might encounter this in the future here is what I did:





                1. In the AndroidManifest.XML define the intent just like I did, but make sure there is a home also. Obviously what you want the app to do when it does open can be different, seems to be a lot of info on that around so I am not including it here. For each action you want to trigger off of, add a new data section:



                    <activity
                  android:name="com.myapp.StartActivity"
                  android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
                  android:label="StartActivity"
                  android:launchMode="singleTask"
                  android:windowSoftInputMode="stateHidden" >
                  <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="myapp" android:host="anondispatch"/>
                  <data android:scheme="myapp" android:host="dispatch"/>
                  <data android:scheme="myapp" android:host="openform"/>
                  <data android:scheme="myapp" android:host="opendispatch"/>
                  </intent-filter>
                  </activity>



                2. In the code you can catch the opening in the onIntent() method in the specified activity (in my example it is StartActivity). Here is a sample of the code parsing out the elements you are looking for:



                  protected void onNewIntent(Intent intent) {
                  super.onNewIntent(intent);
                  setIntent(intent);
                  Intent intent = getIntent();
                  if (intent.getAction() != null) {
                  if (Intent.ACTION_VIEW.equals(intent.getAction())) {
                  Uri uri = intent.getData();
                  String host = uri.getHost(); `
                  String uriStr = uri.toString();
                  if (host.equalsIgnoreCase("anondispatch")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("opendispatch")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("openform")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("dispatch)) {
                  // parse out that you want
                  }
                  }
                  }
                  }
                  }



                3. Update the configuration, from the Edit Configuration so the debugger can run on a remote device via USB by using the following:



                enter image description here






                share|improve this answer













                So, it would seem that there are several problems to what I was doing. What is interesting is that the way the AndroidManifest.xml was configured some 4 years ago seemed to be working, but to run in Android Studio not only does the scheme need to be specified but also the home in the Intent. In my case I have several actions associated with the same scheme, so the answer was to have multiple data sections within the same intent. I could not find any Android documentation on that, but I could have just missed it. So for anyone who might encounter this in the future here is what I did:





                1. In the AndroidManifest.XML define the intent just like I did, but make sure there is a home also. Obviously what you want the app to do when it does open can be different, seems to be a lot of info on that around so I am not including it here. For each action you want to trigger off of, add a new data section:



                    <activity
                  android:name="com.myapp.StartActivity"
                  android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
                  android:label="StartActivity"
                  android:launchMode="singleTask"
                  android:windowSoftInputMode="stateHidden" >
                  <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="myapp" android:host="anondispatch"/>
                  <data android:scheme="myapp" android:host="dispatch"/>
                  <data android:scheme="myapp" android:host="openform"/>
                  <data android:scheme="myapp" android:host="opendispatch"/>
                  </intent-filter>
                  </activity>



                2. In the code you can catch the opening in the onIntent() method in the specified activity (in my example it is StartActivity). Here is a sample of the code parsing out the elements you are looking for:



                  protected void onNewIntent(Intent intent) {
                  super.onNewIntent(intent);
                  setIntent(intent);
                  Intent intent = getIntent();
                  if (intent.getAction() != null) {
                  if (Intent.ACTION_VIEW.equals(intent.getAction())) {
                  Uri uri = intent.getData();
                  String host = uri.getHost(); `
                  String uriStr = uri.toString();
                  if (host.equalsIgnoreCase("anondispatch")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("opendispatch")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("openform")) {
                  // parse out that you want
                  }
                  else if (host.equalsIgnoreCase("dispatch)) {
                  // parse out that you want
                  }
                  }
                  }
                  }
                  }



                3. Update the configuration, from the Edit Configuration so the debugger can run on a remote device via USB by using the following:



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 21:33









                Stephen McCormickStephen McCormick

                771826




                771826
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420951%2fandroid-studio-deep-link-using-uri%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                    SQL update select statement

                    WPF add header to Image with URL pettitions [duplicate]