Loading asset from outside main activity.

Put your problem here if it does not fit any of the other categories.

Loading asset from outside main activity.

Postby maximus-dev » Mon Nov 30, 2009 1:23 am

1st of all, what the heck is with the delay at the android beginners google group?!?!?

anyway... the question as I posted it there (more or less).
Hello everyone,

Again, right upfront... I have to admit to being brand new to Java and
OOP (though not to structured programming) and I'm drowning a bit...

From digging around a bit, getAssets() is an inherited method from
ContextWrapper. It returns an AssetManager, and using open() it can
return an InputStream.

What I'm attempting to do at this point, is use the
GLSurfuceViewActivity, Cube and CubeRenderer examples to work off of and read
in vertex data from a binary file. I've already created the binary
output by parsing a model obj file and added to the assets directory.

My Shape class (modified from the Cube class example) does not have access to
calling getAssets() since it's not a subclass of Activity or
ContextWrapper. Once I accepted that, I tried to think of the best way
to read in the data (without storing it extra places) to the Shape

What I did, and seems to be working okay, was modify the Shape and
ShapeRenderer constructors to accept an AssetManger as a parameter. In
the main Activity I'm passing getAssets() which is passed to the Shape constructor as well.

Does this sound reasonable or totally off base?
Posts: 2
Joined: Mon Nov 16, 2009 4:18 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 4 guests