我有一个自定义文件类型/扩展名,我想与我的应用程序关联.
据我所知,数据元素是为此目的而制作的,但我无法使其正常工作. http://developer.android.com/guide/topics/manifest/data-element.html 根据文档和很多论坛帖子,它应该像这样工作:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/pdf" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
好吧,它不起作用.我做错了什么?我只想声明自己的文件类型.
我想要的是:能够通过邮件发送我的自定义文件,并使用我的应用程序从GMail中的预览按钮导入它,或者在文件浏览器中打开它.
我所知道的:我已经阅读了很多自定义mime类型处理程序,android不关心文件扩展等,但是如何为我的自定义文件创建mime类型?
问题:我需要成为内容提供商吗?我只想导入文件(来自备份)不提供任何东西.我见过人们有"application/abc"的处理程序说它工作正常,但是如何为我的文件"myFile.abc"和mime类型添加该连接?
如何注册/映射自定义mime类型的一些方向将不胜感激!:)
我看到许多使用pathPattern定义特定文件扩展名/类型的intent-filter的例子; 例如,pathPattern=".*\\.xyz".
不幸的是,如果有问题的文件在路径的其他地方有一段时间,这似乎不能正常工作; 例如"my.filename.xyz".
是否有一个与"myfilename.xyz"和"my.filename.xyz"匹配的pathPattern语法?
我无法让我的应用程序在移动设备上注册epub文件.我的android清单中有一组intent过滤器,但它仍然无法在sd卡上打开epub文件.当我浏览File Explorer应用程序时,它会显示该文件,但是当我点击它时,它会显示"系统不支持这种类型的文件:".当我从Internet下载文件,然后使用下载应用程序导航到下载文件夹时,该文件根本不显示(即使它位于文件浏览器的下载文件夹中).我也尝试使用文件选择器intent(Intent.ACTION_OPEN_DOCUMENT)来显示epub文件,但没有运气.我猜测最后两个没有显示,因为意图加载Intent.CATEGORY_OPENABLE
我尝试了多个epub文件,但都没有成功.
有人可以帮助弄清楚我错过了什么吗?
使用KitKat和更高级别的手机.
注意:这个确实从互联网上下载的工作.如果我转到epub链接,这是有效的,但不是来自文件系统.
<!-- Open File Types -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="*" android:scheme="file"/>
<data android:pathPattern=".*\\.epub"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="*" android:scheme="file" android:mimeType="text/plain"/>
<data android:pathPattern=".*\\.epub"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="*" android:scheme="file"/>
<data android:mimeType="application/epub+zip"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="*" android:scheme="http"/>
<data android:pathPattern=".*\\.epub"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="*" android:scheme="http" android:mimeType="text/plain"/>
<data android:pathPattern=".*\\.epub"/> …Run Code Online (Sandbox Code Playgroud) 注册即可打开自定义类型的文件.假设我有.cool文件,如果用户试图打开它,Android会询问他们是否愿意使用我的应用程序打开它.怎么样?
将文件推送到Nexus One时出现问题.
在我看来,我的手机只接受了一小部分文件类型(例如jpg,gif等).
我最近试图将其他文件推送到我的手机(在我的情况下是gpx),我的手机自动拒绝了.
有没有办法在我的程序中绕过或扩展此过滤器?
还有一种方法可以通过服务捕获这些文件吗?
如何让我的Android应用程序成为打开某种文件类型的默认应用程序?
我试图清除默认值,但选项是灰色的,有谁知道如何做到这一点?
我想用something.whateverandroid中的文件打开我的应用程序.
我有两种自定义文件类型,我的应用程序可以处理这些文件类型,我希望能够从各种其他应用程序中打开它们。我为许多人(包括Gmail和“设置”文件浏览器)工作的东西,但是还有一些第三种文件管理器(包括Samsung My Files和Astro File Manager)无法识别这些文件类型属于我的应用程序。有没有一种方法可以使这些文件浏览器应用程序识别出应该由我的应用程序打开这些文件的意图过滤器?
这是现有的意图过滤器:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- See http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension/2062112#2062112 -->
<!--
Capture content by MIME type, which is how Gmail broadcasts
attachment open requests. pathPattern and file extensions
are ignored, so the MIME type *MUST* be explicit, otherwise
we will match absolutely every file opened.
-->
<intent-filter
android:icon="@drawable/book"
android:label="@string/app_name"
android:priority="50">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<!-- needed for properly formatted email messages -->
<data
android:mimeType="application/vnd.bloom"
android:scheme="content" />
<!-- …Run Code Online (Sandbox Code Playgroud) 想要创建一个Android应用程序,它打开一个自定义构建文件扩展名(例如,我想打开.abcd文件)
它类似于Adobe Reader,可打开.pdf文件或打开.jpg文件的Photo Viewer
具体条件:
1..abcd文件应位于应用程序本身的外部/外部.(.pdf是Adobe Reader)
2..abcd文件是一个压缩文件,包含几个文件夹和.xml,.txt和.jpg文件.我想,我想提取它-也许暂时-在存储的地方(当然需要一个拉链/ unzipper库),然后读取个人的.xml,.txt和.jpg文件.
寻找这个问题的见解和答案.
附加信息:
我对Android编程比较陌生.
男装,
我正在努力让我的Android应用程序可以响应正在打开的文件(通过匹配其扩展名)和mime类型(因此它们将在浏览器中工作).
我遵循了这里的建议:
但仍然没有运气.
我的android清单文件中的相关部分如下:
<activity android:name="MuPDFActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/vnd.ms-xpsdocument"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/pdf"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/x-cbz"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.xps"/>
<data android:host="*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.pdf"/>
<data android:host="*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.cbz"/>
<data …Run Code Online (Sandbox Code Playgroud) android ×10
file ×2
blacklist ×1
bluetooth ×1
epub ×1
file-type ×1
handle ×1
intentfilter ×1
mime-types ×1