You say you are -instantiating- an AssetManager? Generally what one does is just hand the Context to whatever function needs to access resources/assets/whatever, and let it retrieve what it needs from that. Context is the main handle on the information about your app. Do be sure, though, if you are handing your Activity (which is a Context) to some other code, that it doesn't hold on to this in some static globals, since that can lead to major leaks (since the Activity/Context basically holds the entire world of that activity, including UI, bitmaps, and everything related). If you really need a Context in globals, you can use getApplicationContext to retrieve the global context for your app.
On Mon, Nov 30, 2009 at 1:17 PM, Jeremiah Sellars <[email protected]>wrote: > (I did post this to the beginners group, but it's been several days > without response. Let me know if a double post like this is frowned > upon... It feels like a basic question, but anyway...) > > Hello everyone, > > 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 to work and learn 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) 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 > class. > > 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 added a private AssetManager, instatiated it in > the onCreate() method from the main Activity, and passed that into the > Renderer like so: > > am = getAssets(); > mGLSurfaceView.setRenderer(new ShapeRenderer(am)); > > Does this sound reasonable or totally off base? > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

