的AndroidManifest.xml:
<provider android:authorities="com.mygame.expansion" android:exported="false" android:multiprocess="true" android:name="org.apache.cordova.xapkreader.XAPKProvider" />
我有一个APEZProvider
类,来自Android SDK / extras文件夹。它扩展了ContentProvider
。
我还有一个XAPKProvider
类,它扩展了APEZProvider
:
public class XAPKProvider extends APEZProvider {
@Override public String getAuthority () {return "com.mygame.expansion";}
public int mainFileVersion = 0;
public int patchFileVersion = 0;
@Override public boolean initIfNecessary () {
if (mInit) return true;
Context ctx = getContext ();
try {
mAPKExtensionFile = APKExpansionSupport.getAPKExpansionZipFile (ctx, mainFileVersion, patchFileVersion);
mInit = true;
return true;
} catch (IOException e) {
e.printStackTrace ();
}
return false;
}
}
如何访问AndroidManifest.xml文件中创建的ContentProvider
对象,以便我可以修改mainFileVersion
和patchFileVersion
变量?
答案 0 :(得分:0)
我发现另一个StackOverflow post让我得到答案。我需要覆盖&#34;呼叫&#34;。例如:
ContentResolver cr = cordova.getActivity().getApplicationContext().getContentResolver();
String expansionAuthority = bundle.getString("expansion_authority", "");
cr.call (Uri.parse("content://" + expansionAuthority), "set_expansion_file_versions", null, bundle);
然后:..
@Override public Bundle call (String method, String arg, Bundle bundle) {
if (method.equals("set_expansion_file_versions")) {
mainFileVersion = bundle.getInt("main_version" , 1);
patchFileVersion = bundle.getInt("patch_version", 1);
expansionAuthority = bundle.getString("expansion_authority", "com.sample.expansion");
xmlDataReceived = true;
return null;
}
return null;
}