about uscontact

특정 확장자의 파일을 Activity와 연동시키기

Author: zemna
Date: April 17, 2021
Share this:

출처 : http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension

Here is how I defined my activity in my AndroidManifest.xml to get this to work.

[code lang="java"]


The scheme of "file" indicates that this should happen when a local file is opened (rather than protocol like http).

mimeType can be set to "*" to match any mime type.

pathPattern is where you specify what extension you want to match (in this example .kdb). The ".*" at the beginning matches any squence of characters. These strings require double escaping, so "." matches a literal period. Then, you end with your file extension.

Finally, according to the Android documentation, both host and scheme attributes are required for the_pathPattern_ attribute to work, so just set that to the wildcard to match anything.

Now, if you select a .kdb flie in an app like Linda File Manager, my app shows up as an option. I should note that this alone does not allow you to download this filetype in a browser, since this only registers with the file scheme. Having an app like Linda File Manager on your phone resisters itself generically allowing you to download any file type.

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *


Professional software development agency estalished in Indonesia. We offers website setup, web application development, fulfillment service, and etc.
Follow us
Follow us to get latest news and tutorials.
2022 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️