How to get user input values from Intent when using Google assistance to interact with my app?











up vote
0
down vote

favorite












Hey I am using ACTION_CREATE_NOTE and SEARCH_ACTION in my app to create a note and search for a note by text in my app.



The search action is working fine as I am getting the search query <My query>
when I speak the following in google assistance "Search for <My query> in <My app>".


Problem is with ACTION_CREATE_NOTE as I am not getting the note text or title or text query, all are null. Can anyone please help.


Here is what I did.

Manifest entry:



<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.gms.actions.CREATE_NOTE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>


Activity code:



    override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
handleIntent(intent)
}

private fun handleIntent(intent: Intent?) {
val action = intent?.action
if (NoteIntents.ACTION_CREATE_NOTE == action) {
//Test this from command line
//adb shell am start -a com.google.android.gms.actions.CREATE_NOTE -n <yourPackageName>/.MainActivity
val name = intent.getStringExtra(NoteIntents.EXTRA_NAME)
val text = intent.getStringExtra(NoteIntents.EXTRA_TEXT)
val query = intent.getStringExtra(NoteIntents.EXTRA_NOTE_QUERY)
Toast.makeText(this, "$name $text $query", Toast.LENGTH_LONG).show()
}
if (Intent.ACTION_WEB_SEARCH == action) {
//Test this from command line
//adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query "Search for something" <yourPackageName>
val query = intent.getStringExtra(SearchManager.QUERY)
Toast.makeText(this, "Query: $query", Toast.LENGTH_LONG).show()
}
}


For Search (which is working)

INPUT: Say following to google assistance: "Search for nearby stations in my app"

OUTPUT: Toast message - "Query: nearby stations"



For Create a note (not working)

INPUT: Say following to google assistance: "take a note to remind me to get milk"

OUTPUT: Toast message - "null null null"



NOTE: App is uploaded on internal release on play store that is why search is working. Otherwise, the search will also not work.



Thanks in advance.










share|improve this question




























    up vote
    0
    down vote

    favorite












    Hey I am using ACTION_CREATE_NOTE and SEARCH_ACTION in my app to create a note and search for a note by text in my app.



    The search action is working fine as I am getting the search query <My query>
    when I speak the following in google assistance "Search for <My query> in <My app>".


    Problem is with ACTION_CREATE_NOTE as I am not getting the note text or title or text query, all are null. Can anyone please help.


    Here is what I did.

    Manifest entry:



    <intent-filter>
    <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <intent-filter>
    <action android:name="com.google.android.gms.actions.CREATE_NOTE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
    </intent-filter>


    Activity code:



        override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    handleIntent(intent)
    }

    private fun handleIntent(intent: Intent?) {
    val action = intent?.action
    if (NoteIntents.ACTION_CREATE_NOTE == action) {
    //Test this from command line
    //adb shell am start -a com.google.android.gms.actions.CREATE_NOTE -n <yourPackageName>/.MainActivity
    val name = intent.getStringExtra(NoteIntents.EXTRA_NAME)
    val text = intent.getStringExtra(NoteIntents.EXTRA_TEXT)
    val query = intent.getStringExtra(NoteIntents.EXTRA_NOTE_QUERY)
    Toast.makeText(this, "$name $text $query", Toast.LENGTH_LONG).show()
    }
    if (Intent.ACTION_WEB_SEARCH == action) {
    //Test this from command line
    //adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query "Search for something" <yourPackageName>
    val query = intent.getStringExtra(SearchManager.QUERY)
    Toast.makeText(this, "Query: $query", Toast.LENGTH_LONG).show()
    }
    }


    For Search (which is working)

    INPUT: Say following to google assistance: "Search for nearby stations in my app"

    OUTPUT: Toast message - "Query: nearby stations"



    For Create a note (not working)

    INPUT: Say following to google assistance: "take a note to remind me to get milk"

    OUTPUT: Toast message - "null null null"



    NOTE: App is uploaded on internal release on play store that is why search is working. Otherwise, the search will also not work.



    Thanks in advance.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Hey I am using ACTION_CREATE_NOTE and SEARCH_ACTION in my app to create a note and search for a note by text in my app.



      The search action is working fine as I am getting the search query <My query>
      when I speak the following in google assistance "Search for <My query> in <My app>".


      Problem is with ACTION_CREATE_NOTE as I am not getting the note text or title or text query, all are null. Can anyone please help.


      Here is what I did.

      Manifest entry:



      <intent-filter>
      <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
      <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
      <intent-filter>
      <action android:name="com.google.android.gms.actions.CREATE_NOTE" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="*/*" />
      </intent-filter>


      Activity code:



          override fun onNewIntent(intent: Intent?) {
      super.onNewIntent(intent)
      handleIntent(intent)
      }

      private fun handleIntent(intent: Intent?) {
      val action = intent?.action
      if (NoteIntents.ACTION_CREATE_NOTE == action) {
      //Test this from command line
      //adb shell am start -a com.google.android.gms.actions.CREATE_NOTE -n <yourPackageName>/.MainActivity
      val name = intent.getStringExtra(NoteIntents.EXTRA_NAME)
      val text = intent.getStringExtra(NoteIntents.EXTRA_TEXT)
      val query = intent.getStringExtra(NoteIntents.EXTRA_NOTE_QUERY)
      Toast.makeText(this, "$name $text $query", Toast.LENGTH_LONG).show()
      }
      if (Intent.ACTION_WEB_SEARCH == action) {
      //Test this from command line
      //adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query "Search for something" <yourPackageName>
      val query = intent.getStringExtra(SearchManager.QUERY)
      Toast.makeText(this, "Query: $query", Toast.LENGTH_LONG).show()
      }
      }


      For Search (which is working)

      INPUT: Say following to google assistance: "Search for nearby stations in my app"

      OUTPUT: Toast message - "Query: nearby stations"



      For Create a note (not working)

      INPUT: Say following to google assistance: "take a note to remind me to get milk"

      OUTPUT: Toast message - "null null null"



      NOTE: App is uploaded on internal release on play store that is why search is working. Otherwise, the search will also not work.



      Thanks in advance.










      share|improve this question















      Hey I am using ACTION_CREATE_NOTE and SEARCH_ACTION in my app to create a note and search for a note by text in my app.



      The search action is working fine as I am getting the search query <My query>
      when I speak the following in google assistance "Search for <My query> in <My app>".


      Problem is with ACTION_CREATE_NOTE as I am not getting the note text or title or text query, all are null. Can anyone please help.


      Here is what I did.

      Manifest entry:



      <intent-filter>
      <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
      <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
      <intent-filter>
      <action android:name="com.google.android.gms.actions.CREATE_NOTE" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="*/*" />
      </intent-filter>


      Activity code:



          override fun onNewIntent(intent: Intent?) {
      super.onNewIntent(intent)
      handleIntent(intent)
      }

      private fun handleIntent(intent: Intent?) {
      val action = intent?.action
      if (NoteIntents.ACTION_CREATE_NOTE == action) {
      //Test this from command line
      //adb shell am start -a com.google.android.gms.actions.CREATE_NOTE -n <yourPackageName>/.MainActivity
      val name = intent.getStringExtra(NoteIntents.EXTRA_NAME)
      val text = intent.getStringExtra(NoteIntents.EXTRA_TEXT)
      val query = intent.getStringExtra(NoteIntents.EXTRA_NOTE_QUERY)
      Toast.makeText(this, "$name $text $query", Toast.LENGTH_LONG).show()
      }
      if (Intent.ACTION_WEB_SEARCH == action) {
      //Test this from command line
      //adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query "Search for something" <yourPackageName>
      val query = intent.getStringExtra(SearchManager.QUERY)
      Toast.makeText(this, "Query: $query", Toast.LENGTH_LONG).show()
      }
      }


      For Search (which is working)

      INPUT: Say following to google assistance: "Search for nearby stations in my app"

      OUTPUT: Toast message - "Query: nearby stations"



      For Create a note (not working)

      INPUT: Say following to google assistance: "take a note to remind me to get milk"

      OUTPUT: Toast message - "null null null"



      NOTE: App is uploaded on internal release on play store that is why search is working. Otherwise, the search will also not work.



      Thanks in advance.







      android






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 17:43









      Nick Felker

      5,46111021




      5,46111021










      asked Nov 9 at 7:39









      Rana Ranvijay Singh

      3,47832541




      3,47832541





























          active

          oldest

          votes











          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',
          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%2f53221566%2fhow-to-get-user-input-values-from-intent-when-using-google-assistance-to-interac%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53221566%2fhow-to-get-user-input-values-from-intent-when-using-google-assistance-to-interac%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







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          JBPM : POST request for execute process go wrong