当前位置:首页 » 文件管理 » asset文件夹

asset文件夹

发布时间: 2024-12-21 13:01:47

‘壹’ 如何打开assets文件夹中的apk

在自己的app中安装assets目录下的apk文件的方法:

详细过程如下:

{

ContextmContext;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mContext=this;

//Toast.makeText(this,""+Environment.getExternalStorageDirectory().getAbsolutePath(),0).show();

if(ApkFromAssets(this,"test.apk",Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.apk")){

Builderm=newAlertDialog.Builder(mContext)

.setIcon(R.drawable.ic_launcher).setMessage("是否安装?")

.setIcon(R.drawable.ic_launcher)

.setPositiveButton("yes",newOnClickListener(){

@Override

publicvoidonClick(DialogInterfacedialog,intwhich){

Intentintent=newIntent(Intent.ACTION_VIEW);

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

intent.setDataAndType(Uri.parse("file://"+Environment.getExternalStorageDirectory().getAbsolutePath()+"/test.apk"),

"application/vnd.android.package-archive");

mContext.startActivity(intent);

}

});

m.show();

}

}

publicbooleanApkFromAssets(Contextcontext,StringfileName,Stringpath){

booleanIsFinish=false;

try{

InputStreamis=context.getAssets().open(fileName);

Filefile=newFile(path);

file.createNewFile();

FileOutputStreamfos=newFileOutputStream(file);

byte[]temp=newbyte[1024];

inti=0;

while((i=is.read(temp))>0){

fos.write(temp,0,i);

}

fos.close();

is.close();

IsFinish=true;

}catch(IOExceptione){

e.printStackTrace();

}

returnIsFinish;

}

}

‘贰’ 为什么我的世界1.7.2assets没有minecraft文件夹

asset文件夹在1.7时代就已经被被替换成了材质+声音的原版资源包文件夹了。
请在
version文件夹→版本
里寻找jar
因为问题没有出详细,所以我的回答可能不会解决你的问题。

热点内容
买服务器如何砍价 发布:2025-09-15 21:04:27 浏览:820
我的世界直连服务器的区别 发布:2025-09-15 20:59:12 浏览:62
哈夫曼树构造算法 发布:2025-09-15 17:18:48 浏览:133
c语言函数要素 发布:2025-09-15 16:39:10 浏览:443
java读ftp文件 发布:2025-09-15 16:15:45 浏览:438
sql随机函数 发布:2025-09-15 15:20:19 浏览:107
校园服务器禁止设置ip 发布:2025-09-15 15:11:06 浏览:784
android刷回 发布:2025-09-15 14:54:24 浏览:591
n后问题算法 发布:2025-09-15 14:38:17 浏览:401
压缩机绝缘 发布:2025-09-15 14:31:10 浏览:550