Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is how I defined my activity in my AndroidManifest.xml to get this to work.</p> <pre><code>&lt;activity android:name="com.keepassdroid.PasswordActivity"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;category android:name="android.intent.category.BROWSABLE" /&gt; &lt;data android:scheme="file" /&gt; &lt;data android:mimeType="*/*" /&gt; &lt;data android:pathPattern=".*\\.kdb" /&gt; &lt;data android:host="*" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>The <code>scheme</code> of <code>file</code> indicates that this should happen when a local file is opened (rather than protocol like HTTP).</p> <p><code>mimeType</code> can be set to <code>\*/\*</code> to match any mime type.</p> <p><code>pathPattern</code> is where you specify what extension you want to match (in this example <code>.kdb</code>). The <code>.*</code> at the beginning matches any squence of characters. These strings require double escaping, so <code>\\\\.</code> matches a literal period. Then, you end with your file extension. One caveat with pathPattern is that <code>.*</code> is not a greedy match like you would expect if this was a regular expression. This pattern will fail to match paths that contain a <code>.</code> before the <code>.kdb</code>. For a more detailed discussion of this issue and a workaround see <a href="https://stackoverflow.com/questions/3400072/pathpattern-to-match-file-extension-does-not-work-if-a-period-exists-elsewhere-i/8599921#8599921">here</a></p> <p>Finally, according to the Android documentation, both <code>host</code> and <code>scheme</code> attributes are required for the <code>pathPattern</code> attribute to work, so just set that to the wildcard to match anything.</p> <p>Now, if you select a <code>.kdb</code> file 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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload