我已经开发了应用程序并成功运行.
我在应用程序中使用了应用程序许可功能.现在我要在谷歌播放上传一个应用程序.
请让我知道步骤,如何使用应用程序许可以及如何创建APK扩展文件?
从扩展文件中读取mp3文件
我有名称的创建和扩展文件
"main.1.com.example.app.obb"
其中包含和音频文件名"about_eng.mp3"
现在问题我编写了以下代码来阅读和播放mp3文件
private final static String EXP_PATH = "/Android/obb/";
static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) {
String packageName = ctx.getPackageName();
Vector<String> ret = new Vector<String>();
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
// Build the full path to the app's expansion files
File root = Environment.getExternalStorageDirectory();
File expPath = new File(root.toString() + EXP_PATH + packageName);
// Check that expansion file path exists
if (expPath.exists()) {
if ( mainVersion > 0 ) {
String strMainPath = expPath + File.separator + …Run Code Online (Sandbox Code Playgroud) 我正在关注所有官方扩展文件指南,但我找不到它.我无法访问我需要的包含的obb文件.
我需要6个音频文件(80Mb),我在zip文件中"存储"(未压缩)并重命名为"main.2001.test.expansion.proj.obb"并存储在'/ mnt/sdcard/Android/obb/test中.expansion.proj /"
我会尝试访问这些文件
String mainFileName = Helpers.getExpansionAPKFileName(this,true,2001);
if(!Helpers.doesFileExist(this, mainFileName, 27959282L, false))
{
//download
} else {
Log.d("test_file","file exist");
}
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this,2001,2001);
if(expansionFile!=null)
{
ZipEntryRO[] ziro = expansionFile.getAllEntries();
for (ZipEntryRO entry : ziro) {
Log.d("test_files_zip", "fileZip filename: "+entry.getZipFileName());
try{
AssetFileDescriptor ro = entry.getAssetFileDescriptor();
Log.d("test_files_zip", "--fileZip getfiledescriptor.tostring: "+ro.getFileDescriptor().toString());
Log.d("test_files_zip", "--fileZip createinputstring.tostring: "+ro.createInputStream().toString());
AssetFileDescriptor assetFileDescriptor = expansionFile.getAssetFileDescriptor(entry.getZipFileName()+"/audio02.mp3");
if(assetFileDescriptor!=null) {
Log.d("test_files_mp3", "length: "+assetFileDescriptor.getLength()); //checking it exists
}
}catch (IOException e){ Log.e("test_exp","IoExcp: "+e.getMessage()); }
}
}
Run Code Online (Sandbox Code Playgroud)
In - > assetFileDescriptor = …