2

I am trying to use Assist api inside my application, i followed most of the tutorials, but could not find a proper tutorial which will completely tell how it should be implemented. i have added this to the activity. is there anything else to be done in manifest or anywhere in the project. When debugged this below method got called but nothing

@Override
        public void onProvideAssistContent(AssistContent outContent) {
            super.onProvideAssistContent(outContent);

            outContent.setWebUri(Uri.parse("https://commonsware.com"));
            try {
                String structuredJson = new JSONObject()
                        .put("@type", "Book")
                        .put("@author", "https://commonsware.com/mmurphy")
                        .put("publisher", "CommonsWare, LLC")
                        .put("name", "The Busy Coder's Guide to Android          Development")
                        .toString();
                outContent.setStructuredData(structuredJson);
            }catch(JSONException jsonEx){
                Log.e(getClass().getSimpleName(), "What happend", jsonEx);
            }
        }

i am seeing, it always shows NOTHING FOUND ON THE SCREEN when i long tapped the home button

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
androider
  • 23
  • 2
  • "but could not find a proper tutorial which will completely tell how it should be implemented" -- you seem to be using sample code from [my book](https://commonsware.com/Android), which has a chapter on the Assist API. "it always shows NOTHING FOUND ON THE SCREEN" -- do you have anything in your activity's UI? There is no requirement for any assistant to actually use the information supplied via `onProvideAssistContent()`. Also, what is the assistant on your device (i.e., what is getting control when you long-tap HOME)? – CommonsWare Dec 04 '16 at 23:44
  • Hi, What is that "There is no requirement for any assistant to actually use the information supplied via onProvideAssistContent()"? What else i need to add in my project to make it working?, Kindly help – androider Dec 05 '16 at 14:53
  • "What else i need to add in my project to make it working?" -- contact the authors of whatever assistant you are using on your device. You are *offering* data via `onProvideAssistContent()`. No assistant *has* to use that data that you are offering. – CommonsWare Dec 05 '16 at 15:14
  • Suppose if i want to simply open a url through assist api from my application by long tap on home button, what i need to modify, i tried @Override public void onProvideAssistContent(AssistContent outContent) { super.onProvideAssistContent(outContent); outContent.setWebUri(Uri.parse("https://www.yahoo.com")); } but nothing worked – androider Dec 05 '16 at 15:35

1 Answers1

3

i want to simply open a url through assist api from my application by long tap on home button

That is not your decision to make. You can offer a URL to the assistant. What the assistant does with that URL, if anything, is up to the developers of the assistant.

In my tests when the Assist API came out, I concluded that the then-current implementation of Google's Now on Tap ignored onProvideAssistContent(), but that the onProvideAssistContent()-supplied data was available if assistants wanted it.

what i need to modify

To force the assistant to do something with onProvideAssistContent(), you would need to write your own assistant, then convince the user to switch to your assistant.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • is there any sample available for understanding assist api better? – androider Dec 05 '16 at 16:02
  • @androider: I do not know what "it" is. – CommonsWare Dec 05 '16 at 16:04
  • Thanks, @CommonsWare for that answer, I am also struggling for a long time and if you(@androider) are looking for a sample please have a look https://github.com/abhijeetvader9287/-cw-omnibus-master/tree/master/Assist – Subho Dec 19 '18 at 07:07
  • @CommonsWare can you please take a look https://stackoverflow.com/questions/53757510/how-to-integrate-app-action-using-actions-xml ? – Subho Dec 19 '18 at 07:08