Example usage for android.content.res AssetManager getClass

List of usage examples for android.content.res AssetManager getClass

Introduction

In this page you can find the example usage for android.content.res AssetManager getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static AssetManager createAssetManager(String dexPath) {
    try {/*from w w  w  . jav  a2 s .  c  om*/
        AssetManager assetManager = AssetManager.class.newInstance();
        Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
        addAssetPath.invoke(assetManager, dexPath);
        return assetManager;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.ryg.dynamicload.DLProxyFragmentActivity.java

protected void loadResources() {
    try {/*from w  w w  .ja va2 s  . c o m*/
        AssetManager assetManager = AssetManager.class.newInstance();
        Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
        addAssetPath.invoke(assetManager, mDexPath);
        mAssetManager = assetManager;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Resources superRes = super.getResources();
    mResources = new Resources(mAssetManager, superRes.getDisplayMetrics(), superRes.getConfiguration());
}