Skip to content Skip to sidebar Skip to footer

Android Assetmanager Getasset() Throwing Nullpointer Exception

I have 2 classes, from class BinderData, which extends BaseAdapter (I can't extend this class to Activity as I have to extend to BaseAdapter) I am calling class AssetActivity by fo

Solution 1:

AssetManager assets = getAssets(); will give you NullPointerException because getAssets() will return null. getAssets() needs to be called in the Activity Context;

You are not allowed to create Object for the class android will take care of that through life cycle methods. So don't create Object for Activity.

place that method in your Activity class use context.getAssets() to get the Assets

Post a Comment for "Android Assetmanager Getasset() Throwing Nullpointer Exception"