我在android发烧友stackexchange论坛上也提出了类似的问题,但没有给出答案。我把这个问题贴在这里,希望能有更多的人看到,或许能提供一个答案。
这是Android发烧友的帖子:
https://android.stackexchange.com/questions/203123/oreo-associating-an-app-with-all-files-with-a-given-extension
总之,我正在寻找一种方法来告诉我的基于oreo的android系统将一个新后缀与
text/plain
MIME类型。换句话说,假设我希望设备上的所有文件都带有后缀
.abc
被认为是
文本/平原
. 我希望这是一个系统范围的映射,而不仅仅是一个特定应用程序的映射。
说清楚,我是
不
只需寻找一种方法将应用程序与
文本/平原
. 我什么
是
查找是导致所有文件
美国广播公司
后缀
总是
被认为是
文本/平原
在我的设备上。
我知道android下有一些mime类型映射的后缀。例如。
.txt
总是映射到
文本/平原
,正如
.log
还有其他一些后缀。所以至少在理论上,应该可以映射任何后缀(比如
美国广播公司
例)
文本/平原
. 但是,我还没有弄清楚怎么做。
有一个文件叫做
/system/lib/content-types.properties
它似乎提供了这种功能(请参阅下面的“我的设备”中该文件的列表)。但是,当我把
abc=text/plain
在那个文件中,带有
美国广播公司
后缀仍不能识别为
文本/平原
,即使在重新启动之后。
我正在运行一个有xposed和magisk的根设备,因此我可以安装非官方模块。但是,我还没有找到任何xposed或magisk模块提供这种功能。我还可以运行自定义
init.d
脚本,以防有某种方法以这种方式启用此功能。
有人能给我提个建议吗?非常感谢你。
以下是我的
/系统/lib/content-types.properties
文件…
# If you want to support more recognized mimetypes in libcore.net.MimeUtils, add them here
docm=application/vnd.ms-word.document.macroenabled.12
xlsb=application/vnd.ms-excel.sheet.binary.macroenabled.12
xlsm=application/vnd.ms-excel.sheet.macroenabled.12
ppsm=application/vnd.ms-powerpoint.slideshow.macroenabled.12
ppsx=application/vnd.openxmlformats-officedocument.presentationml.slideshow
pptm=application/vnd.ms-powerpoint.presentation.macroenabled.12
asm=text/x-asm
cc=text/x-c
conf=text/plain
cpp=text/x-c
css=text/css
c=text/x-c
cxx=text/x-c
def=text/plain
dic=text/x-c
f77=text/x-fortran
f90=text/x-fortran
for=text/x-fortran
f=text/x-fortran
hh=text/x-c
hpp=text/x-c
h=text/x-c
ics=text/calendar
ifb=text/calendar
in=text/plain
jad=text/vnd.sun.j2me.app-descriptor
java=text/x-java-source
ksh=text/plain
list=text/plain
log=text/plain
pas=text/x-pascal
pl=text/plain
properties=|
prop=text/plain
p=text/x-pascal
py=text/x-python
rc=text/plain
sgml=text/sgml
sgm=text/sgml
s=text/x-asm
vcs=text/x-vcalendar