iApp免会员加载APK或JAR
2018-11-28 本文已影响0人
抹茶NightSky
今天给大家带来iApp免会员加载APK或JAR方法,废话不多说先来看看效果。
iApp免会员加载APK或JAR
下面开始写代码,先新建一个nightsky.myu
//我已经帮大家封装好了方法粘贴下面的代码就好了!
/.QQ2941866567
.这里使用了路径和资源路径
.路径用于获取文件名称防止加载多个文件被替换掉
.资源路径用于iApp的fc来复制文件打包就不用麻烦了
.nloadjar params1 path params2 res
.loadjar
.return ss.dex
./
fn nloadjar(path,res)
fn nightsky.cachedex(path,res)
//获取dex缓存路径
java(dir,activity,"android.content.ContextWrapper.getDir","String","dex","int",0)
java(cachepath,dir,"java.io.File.getAbsolutePath")
//获取当前App加载器
java(cll,activity,"android.content.ContextWrapper.getClassLoader")
java(cl,cll,"java.lang.ClassLoader.getParent")
//加载dex
javanew(ss.dex,"dalvik.system.DexClassLoader","String",ss.dpath,"String",cachepath,"String",null,"java.lang.ClassLoader",cl)
end fn
/.QQ1990613394
.cachedex params1 path params2 res
.dex copy to cache
.return ss.dpath
.吧dex或apk放到res文件夹里面,
.这样打包后也可以加载。
./
fn cachedex(path,res)
javanew(file,"java.io.File","String",path)
java(fname,file,"java.io.File.getName")
java(cpath,activity,"android.content.ContextWrapper.getCacheDir")
java(cfpath,cpath,"java.io.File.getAbsolutePath")
ss(cfpath+"/"+fname,ss.dpath)
fc(res,ss.dpath,e)
syso(e)
end fn
这里用的NX5的DEX先添加一个相对布局
iApp免会员加载APK或JAR
吧高宽最大化!
调用方法如下:
fdir("@NightSkyX5WebView.dex",path)
fn nightsky.nloadjar(path,"@NightSkyX5WebView.dex")
s jar = ss.dex
cls(jar,"com.nightsky.X5WebView",wvc)
main.iyu载入事件:
//QQ2941866567
//核心代码都在nightsky.myu事件中
fdir("@NightSkyX5WebView.dex",path)
fn nightsky.nloadjar(path,"@NightSkyX5WebView.dex")
s jar = ss.dex
cls(jar,"com.nightsky.X5WebView",wvc)
syso(wvc)
javanew(ss.nwv,wvc,"Context",activity)
nvw(ss.nwv,1)
//接口类
cls(jar, "com.nightsky.X5WebView$NightSkyWebViewapi", c2)
//回调监听
javacb(hd, c2)
{
/.回调方法:
.全屏时 Method onShowCustomView return View view
.退出全屏时 Method onHideCustomView return null
.加载进度 Method onProgressChanged return int Progress
.加载完成时 Method onPageFinished return String url
.打开新链接时 Method shouldOverrideUrlLoading return String url
.浏览器浏览文件时 onOpenFileChooser return Object uploadMsg
.下载文件时 Method onDownloadStart return String url, String ut, String cn, String me, long length
./
f(st_mD?"shouldOverrideUrlLoading")
{
//浏览器打开url
sgsz(st_aS,0,url)
//用自己的浏览器打开新的链接
javax(null,ss.nwv,wvc,"setUrl","String",url)
}
//全屏播放影视
f(st_mD?"onShowCustomView")
{
//获取影视窗口
sgsz(st_aS,0,ss.v)
nvw(ss.v,1)
ushsp(true)
}
f(st_mD?"onHideCustomView")
{
ushsp(false)
//移除影视控件
urvw(ss.v)
ss v = null
}
f(st_mD?"onDownloadStart")
{
sgsz(st_aS,0,url)
syso(url)
}
//浏览器浏览器文件时
f(st_mD?"onOpenFileChooser")
{
sit(a, "action", "android.intent.action.GET_CONTENT")
sit(a,"","android.intent.category.OPENABLE")
sit(a, "type", "*/*")
uit(a, "result", 1)
ss wvc = wvc
}
}
//设置api回调接口
javax(null, ss.nwv, wvc, "setWebViewapi", c2, hd)
//获取网页设置
javax(null,ss.nwv,wvc,"setUrl","String","http://fishdeep.ccxyr.top/llytest/re/video.mp4")
java(null,ss.nwv,"android.view.View.requestFocus")
这样就完成了。
Demo下载:iApp免费加载DEX
SDK下载:NightSkyX5WebView