与Android的应用程序相关联的文件类型失败 [英] associate file type with android app fails

查看:220
本文介绍了与Android的应用程序相关联的文件类型失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎,我的应用程序与特定文件类型( .STL )相关联。一项建议<一href="http://stackoverflow.com/questions/4149032/correct-android-intent-filter-configuration-to-associate-a-file-type-with-an-act"标题=点击这里>凯文这里没有任何效果。当试图从文件管理器启动的文件,我的应用程序不是一个选项建议。

他的code是:

 &LT;活动名称=com.mycompany.MyActivity&GT;
    &LT;意向滤光器&gt;
        &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
        &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
        &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
        &lt;数据机器人:MIMETYPE =应用程序/ PDF/&GT;
    &所述; /意图滤光器&gt;
&LT; /活性GT;
 

(除非我有STL不是PDF)。我试着在这个主题上我能找到的所有版本。

系统似乎没有意识到我的应用程序可用于打开这种文件。我做一些愚蠢的事?

非常感谢您的任何建议。

编辑:

我找到了答案。基本上,你必须声明你让任何旧MIMETYPE依靠文件扩展名。使用正确的mimetype(应用/ SLA),没有工作。这工作:

 &lt;数据机器人:计划=文件
      机器人:MIMETYPE =* / *
      。* \\ STL:机器人pathPattern = /&GT;
 

现在,当我选择天文我的应用程序被认为是一种将打开这种文件的文件。

解决方案
  

我挣扎,我的应用程序与特定文件类型(.STL)相关联。

通常情况下,Android不使用文件扩展名来指示类型。 Android使用MIME类型来表示类型。

  

当试图从文件管理器启动的文件,我的应用程序不是一个选项建议。

好了,只保证固答案是:

第1步:确定MIME类型 .STL 文件与

相关

步骤#2:使用MIME类型在&LT;活性GT; 元素安卓MIMETYPE 属性

第三步:强制每一个文件管理器的作者来实现你的MIME类型,当他们遇到 .STL 文件支持

步骤#3中,当然,是问题

Android的,像iOS和其他操作系统,都拼命想掩盖从用户文件的概念。这就是为什么有内置的Andr​​oid,为什么一些设备束中的一个没有文件管理器,为什么会出现在操作系统的概念很少的支持。

欢迎您尝试使用&lt;数据机器人:计划=文件机器人:pathPattern =*。\\ STL/&GT; 在你的&lt;数据&GT; 元素支持的东西根据文件扩展名,虽然我不知道这工作得很好。您可能还需要机器人:主机=*该元素 - 机器人本身并不使用 pathPattern 文件方案,第三方code,我研究显示元素两种方式。同样,我不知道,如果它的工作原理。

I'm struggling to associate my app with a particular file type (.stl). A recommendation here from Kevin doesn't have any effect. When trying to launch a file from a file manager, my app isn't one of the options suggested.

His code is:

<activity name="com.mycompany.MyActivity">
    <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:mimeType="application/pdf" />
    </intent-filter>
</activity>

(Except I have stl not pdf). I've tried all the variations on this theme I can find.

The system seems unaware that my app is available to open this kind of file. Am I doing something stupid?

Many thanks for any suggestions.

EDIT:

I have the answer. Basically you have to state that you are allowing any old mimetype and relying on the file extension. Using the 'correct' mimetype (application/sla) didn't work. This works:

<data android:scheme="file" 
      android:mimeType="*/*" 
      android:pathPattern=".*\\.stl" />

Now when I select a file in Astro my app is suggested as one which will open this kind of file.

解决方案

I'm struggling to associate my app with a particular file type (.stl).

Generally, Android does not use file extensions to indicate type. Android uses MIME types to indicate type.

When trying to launch a file from a file manager, my app isn't one of the options suggested.

Well, the only guaranteed-solid answer is:

Step #1: Determine the MIME type that .stl files are associated with

Step #2: Use that MIME type in your <activity> element for the android:mimeType attribute

Step #3: Force each and every file manager author to implement support for your MIME type for when they encounter .stl files

Step #3, of course, is the problem.

Android, like iOS and other operating systems, are trying desperately to hide the concept of "files" from the user. That is why there is no file manager built into Android, why few devices bundle one, and why there is little support for the concept in the OS.

You are welcome to try to use <data android:scheme="file" android:pathPattern=".*\\.stl" /> in your <data> element to support things based on file extension, though I'm not sure if that works well. You might also need android:host="*" in that element -- Android itself does not use pathPattern for the file scheme, and the third-party code I am examining shows the element both ways. Again, I have no idea if it works.

这篇关于与Android的应用程序相关联的文件类型失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆