Activity.onProvideAssistContent() 示例

Activity.onProvideAssistContent() example

谁能给 mi 一个使用 Activity.onProvideAssistContent() 的例子,Android 6.0 中的新功能?

例如,对于音乐文件,您将使用 MusicRecording 中的 Schema.org 类型:

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

  String structuredJson = new JSONObject()
       .put("@type", "MusicRecording")
       .put("@id", "https://example.com/music/recording")
       .put("name", "Album Title")
       .toString();

  assistContent.setStructuredData(structuredJson);
}

JSON 参数的完整列表,您可以在 Schema.org. And to play with JSON without need to compile app - JSON-LD 网站找到。

添加到 , it's part of the Assist API. I just saw the new documentation for this new feature in Android Marshmallow. It's here: http://developer.android.com/training/articles/assistant.html

长按主页按钮或说出关键短语,助手会显示 window,其中包含当前 activity 的上下文相关操作。这些潜在操作可能包括深入 link 到设备上的其他应用程序。

此 link 提供了使用 Activity.onProvideAssistContent() 的示例:http://developer.android.com/training/articles/assistant.html#source_app