Reputation: 1
how do you access the assets in your asset pack (install-time)? I have made the assets packs but when i install the game, my game doesn't access them as i have not integrated any way to access the assets in asset pack.
i have made asset pack successfully (they have music files mp3)
i googled guide to include this code in my app MainActivity.java:
import android.content.res.AssetManager;
...
Context context = createPackageContext("com.example.app", 0);
AssetManager assetManager = context.getAssets();
InputStream is = assetManager.open("asset-name");
I have also made necessary changes to code
but somewhere this code gets error as i don't know at which location of the main activity should i paste it.
My MainActivity looks like this:
package com.monarchnexus.calmoasis;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
(If that above code is not integrated in it )
Please suggest me a way guys, also tell me at which location in my MainActivity should i put that code
Upvotes: 0
Views: 42