0

AndroidManifest.xml: <provider android:authorities="com.mygame.expansion" android:exported="false" android:multiprocess="true" android:name="org.apache.cordova.xapkreader.XAPKProvider" />

I have an APEZProvider class, which comes from the Android SDK /extras folder. It extends ContentProvider.

I also have a XAPKProvider class, which extends 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;
 }
}

How can I access the ContentProvider object created in the AndroidManifest.xml file, so that I can modify the mainFileVersion and patchFileVersion variables?

Agamemnus
  • 1,395
  • 4
  • 17
  • 41

1 Answers1

0

I found another StackOverflow post that got me to the answer. I needed to override "call". For example:

ContentResolver cr = cordova.getActivity().getApplicationContext().getContentResolver();
String expansionAuthority = bundle.getString("expansion_authority", "");
cr.call (Uri.parse("content://" + expansionAuthority), "set_expansion_file_versions", null, bundle);

Then:..

@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;
}
Community
  • 1
  • 1
Agamemnus
  • 1,395
  • 4
  • 17
  • 41