Intent filter for files only

前端 未结 2 1859
梦谈多话
梦谈多话 2021-02-13 16:48

in our app, we want to appear in the \"Share via\" menu. So we added this intent-filter to our activity :


    

        
相关标签:
2条回答
  • 2021-02-13 17:20

    we want to appear in the menu for all files, whatever there mime type is

    Try a MIME type of */*.

    we want to appear only for files. And up to now, if the user wants to share a simple text, as its mime type will be text/plain, our app appears in the menu and we don't want it. We tried to add scheme=file and host="" or "*" and it doesn't work as many app use a scheme=content to share file based content.

    Then have two <data> elements, one for a scheme of content and one for a scheme of file.

    <data android:mimeType="*/*" />
    <data android:scheme="content" />
    <data android:scheme="file" />
    

    However, bear in mind that a content scheme does not mean that it is necessarily a file.

    0 讨论(0)
  • 2021-02-13 17:22
    1. If you want to be invoked for any mime type, don't place a single mine type in the filter
    2. scheme="file" is the answer to run only on files. Now if the 3rd party applicaiton pass the data as content, then it is (by defiinition) not a file any more
    0 讨论(0)
提交回复
热议问题