最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Android QPython3 擴(kuò)展:調(diào)用其他App打開文件

2021-01-03 22:29 作者:乘著船  | 我要投稿

#需要QPythonSupport基礎(chǔ)窗口??https://www.bilibili.com/read/cv9100444


QPythonSupport/App/src/main/AndroidManifest.xml】添加


? <activity

? ? ? ? ? ? android:label="打開文件服務(wù)"

? ? ? ? ? ? android:name=".OpenFile" >

? ?<intent-filter>

? ? ? ? ? ? ? ? <action android:name="android.intent.action.VIEW" />

? ? ? ? ? ? </intent-filter>

? ? ? ? </activity>


QPythonSupport/App/src/main/java/czc/qpython/support/OpenFile.java


package czc.qpython.support;


import android.App.*;

import android.os.*;

import android.widget.*;

import android.text.*;

import java.io.*;

import android.net.*;

import android.content.*;


public class OpenFile extends Activity

?{

??

? ? @Override

? ? public void onCreate(Bundle savedInstanceState) {

? Main.requestPermissions(this);

? ? ? ? super.onCreate(savedInstanceState);

? Intent intent=getIntent();

? String path=intent.getStringExtra("path");

? String type=intent.getStringExtra("type");

? ? ? ? try {

? ? ? ? ? ? Intent intentO = new Intent();

? ? ? ? ? ? intentO.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

? ? ? ? ? ? intentO.setAction(Intent.ACTION_VIEW);

? ? ? ? ? ? intentO.setDataAndType(Uri.fromFile(new File(path)),type);

? ? ? ? ? ? this.startActivity(intentO);

? ? ? ? ? ? intentO.createChooser(intentO, "請(qǐng)選擇對(duì)應(yīng)的軟件打開該文件!");

? ? ? ? } catch (Exception e) {

? ?Toast.makeText(this,e.toString(),Toast.LENGTH_LONG).show();

? ? ? ? }

? OpenFile.this.finish();

? ? }

}


QPythonSupport/__init__.py】添加


_mineType=eval(open(__file__[:__file__.rfind('/')+1]+'MineType.ini').read())

def OpenFile(Path,Wait=True):

? ? ext=Path[Path.rfind('/')+1:]

? ? ext=ext[ext.rfind('.')+1:].lower()

? ? jsla('startActivity','android.intent.action.VIEW',None,None,{'path':Path,'type':_mineType.get(ext,'*/*')},Wait,'czc.qpython.support','czc.qpython.support.OpenFile')


_a=str(os)

_b=_a.find('com')

_c=_a.find('/',_b)

_qpyPkg=_a[_b:_c]

del _a,_b,_c

def OpenFileWithContentProvider(Path,Extras=None):

? ? #需要 QPython OH 3.1.5 或以上 乘著船修改版

? ? ext=Path[Path.rfind('/')+1:]

? ? ext=ext[ext.rfind('.')+1:].lower()

? ? jsla('view','content://%s.provider/root%s'%(_qpyPkg,Path),_mineType.get(ext,'*/*'),Extras)


QPythonSupport/MineType.ini


{

"3gp":"video/3gpp",

"3gpp":"video/3gpp",

"7z":"Application/x-7z-compressed",

"aac":"audio/x-mpeg",

"amr":"audio/x-mpeg",

"ape":"audio/x-mpeg",

"apk":"Application/vnd.android.package-archive",

"avi":"video/x-msvideo",

"asf":"video/x-ms-asf",

"asp":"Application/x-asap",

"asx":"video/x-ms-asf",

"au":"audio/basic",

"bz2":"Application/x-bzip2",

"bin":"Application/octet-stream",

"bmp":"image/bmp",

"c":"text/plain",

"class":"Application/octet-stream",

"conf":"text/plain",

"cpp":"text/plain",

"cgi":"magnus-internal/cgi",

"chm":"Application/vnd.ms-htmlhelp",

"css":"text/css",

"csv":"text/csv",

"dps":"Application/ksdps",

"doc":"Application/msword",

"docx":"Application/msword",

"dhtml":"text/html",

"dll":"Application/octet-stream",

"dmg":"Application/octet-stream",

"dms":"Application/octet-stream",

"eps":"Application/postscript",

"epub":"Application/epub+zip",

"et":"Application/kset",

"exe":"Application/octet-stream",

"flac":"audio/x-mpeg",

"flv":"video/x-msvideo",

"gif":"image/gif",

"gps":"Application/x-gps",

"gtar":"Application/x-gtar",

"gz":"Application/x-gzip",

"h":"text/plain",

"htm":"text/html",

"html":"text/html",

"hlp":"Application/winhlp",

"hqx":"Application/mac-binhex40",

"ico":"Application/octet-stream",

"jar":"Application/java-archive",

"java":"text/plain",

"jpeg":"image/jpeg",

"jpg":"image/jpeg",

"js":"Application/x-javascript",

"log":"text/plain",

"lrc":"text/plain",

"m3u":"audio/x-mpegurl",

"map":"magnus-internal/imagemap",

"mht":"message/rfc822",

"mhtml":"message/rfc822",

"mid":"audio/midi",

"midi":"audio/midi",

"m4a":"audio/mp4a-latm",

"m4u":"video/vnd.mpegurl",

"m4v":"video/x-m4v",

"mov":"video/quicktime",

"mp2":"audio/x-mpeg",

"mp3":"audio/x-mpeg",

"mp4":"video/mp4",

"mpeg":"video/mpeg",

"mpg":"video/mpeg",

"ogg":"audio/ogg",

"pcx":"image/x-pcx",

"pda":"image/x-pda",

"pdf":"Application/pdf",

"png":"image/png",

"pnz":"image/png",

"pot":"Application/vnd.ms-powerpoint",

"pps":"Application/vnd.ms-powerpoint",

"ppsx":"Application/vnd.ms-powerpoint",

"ppt":"Application/vnd.ms-powerpoint",

"pptx":"Application/vnd.ms-powerpoint",

"ps":"Application/postscript",

"pub":"Application/x-mspublisher",

"py":"text/plain",

"pyw":"text/plain",

"qt":"video/quicktime",

"qti":"image/x-quicktime",

"qtif":"image/x-quicktime",

"ra":"audio/x-pn-realaudio",

"ram":"audio/x-pn-realaudio",

"rgb":"image/x-rgb",

"rm":"audio/x-pn-realaudio",

"rmm":"audio/x-pn-realaudio",

"rnx":"Application/vnd.rn-realplayer",

"rp":"image/vnd.rn-realpix",

"rt":"text/vnd.rn-realtext",

"rtf":"Application/rtf",

"rar":"Application/x-rar-compressed",

"rmvb":"audio/x-pn-realaudio",

"swf":"Application/x-shockwave-flash",

"swfl":"Application/x-shockwave-flash",

"tar":"Application/x-tar",

"taz":"Application/x-tar",

"tgz":"Application/x-tar",

"tif":"image/tiff",

"tiff":"image/tiff",

"ttf":"Application/octet-stream",

"txt":"text/plain",

"vcd":"Application/x-cdlink",

"vcf":"text/x-vcard",

"viv":"video/vivo",

"vivo":"video/vivo",

"wav":"audio/x-wav",

"wma":"audio/x-ms-wma",

"wmv":"audio/x-ms-wmv",

"wps":"Application/kswps",

"wri":"Application/x-mswrite",

"x-gzip":"Application/x-gzip",

"xht":"Application/xhtml+xml",

"xhtm":"Application/xhtml+xml",

"xhtml":"Application/xhtml+xml",

"xla":"Application/vnd.ms-excel",

"xlc":"Application/vnd.ms-excel",

"xll":"Application/x-excel",

"xlm":"Application/vnd.ms-excel",

"xls":"Application/vnd.ms-excel",

"xlsx":"Application/vnd.ms-excel",

"xlt":"Application/vnd.ms-excel",

"xlw":"Application/vnd.ms-excel",

"xml":"text/xml",

"z":"Application/x-compress",

"zip":"Application/zip"

}


QPythonSupport/說明.txt】添加



? OpenFile(Path,Wait=True)

? 調(diào)用其他App打開文件(路徑,等待=是)

? 路徑格式:/sdcard/xxx/yyy.zzz

? 使用file://方式

? 可以修改MineType.ini文件

??

? OpenFileWithContentProvider(Path,Extras=None)

? 調(diào)用其他App打開文件(路徑,額外信息=無)

? 路徑格式:/sdcard/xxx/yyy.zzz

? 必須等待文件操作完成

? 使用ContentProvider方式

??需要 QPython OH 3.1.5 或以上 乘著船修改版

? 其余類似OpenFile


視頻:https://www.bilibili.com/video/BV185411H7L7

新的QPython打開文件方法:https://www.bilibili.com/read/cv11037013


作者:乘著船@Bilibili

更多文章+下載鏈接:https://www.bilibili.com/read/readlist/rl321663


Android QPython3 擴(kuò)展:調(diào)用其他App打開文件的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
深泽县| 名山县| 沈丘县| 安国市| 五家渠市| 青田县| 翁源县| 西平县| 秦安县| 大城县| 昌吉市| 靖宇县| 乌恰县| 云林县| 新疆| 循化| 阿坝| 静乐县| 武功县| 文登市| 宜兰市| 邮箱| 文昌市| 杭锦后旗| 华坪县| 石台县| 鸡西市| 禄劝| 安多县| 抚顺县| 清远市| 巴彦淖尔市| 新余市| 若羌县| 柳江县| 如东县| 寻甸| 嘉鱼县| 凤城市| 繁昌县| 体育|