java类android.content.res.AssetManager的实例源码

FileUtils.java 文件源码 项目:Sense-Hub-Android-Things 阅读 34 收藏 0 点赞 0 评论 0
public static InputStream readAssetsFileToStream(String fileName, Context context) {
    AssetManager assManager = context.getAssets();
    InputStream is = null;
    try {
        is = assManager.open(fileName);
    } catch (Exception e) {
        e.getMessage();
    } finally {
        try {
            if (is != null)
                is.close();
        } catch (Exception e2) {
            e2.getMessage();
        }
    }
    InputStream isOutput = new BufferedInputStream(is);
    return isOutput;
}
StreamUtils.java 文件源码 项目:LiuAGeAndroid 阅读 39 收藏 0 点赞 0 评论 0
/**
 * 读取Assets下的文本文件
 *
 * @param context  上下文
 * @param fileName 文件名
 * @return 读取到的字符串
 */
public static String readAssetsFile(Context context, String fileName) {

    StringBuilder stringBuffer = new StringBuilder();
    AssetManager assetManager = context.getAssets();
    try {
        InputStream is = assetManager.open(fileName);
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String str = null;
        while ((str = br.readLine()) != null) {
            stringBuffer.append(str);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return stringBuffer.toString();
}
IconThemer.java 文件源码 项目:LaunchEnr 阅读 42 收藏 0 点赞 0 评论 0
private Drawable getRoundIcon(Context context,String packageName, int iconDpi) {

        mPackageManager = context.getPackageManager();

        try {
            Resources resourcesForApplication = mPackageManager.getResourcesForApplication(packageName);
            AssetManager assets = resourcesForApplication.getAssets();
            XmlResourceParser parseXml = assets.openXmlResourceParser("AndroidManifest.xml");
            int eventType;
            while ((eventType = parseXml.nextToken()) != XmlPullParser.END_DOCUMENT)
                if (eventType == XmlPullParser.START_TAG && parseXml.getName().equals("application"))
                    for (int i = 0; i < parseXml.getAttributeCount(); i++)
                        if (parseXml.getAttributeName(i).equals("roundIcon"))
                            return resourcesForApplication.getDrawableForDensity(Integer.parseInt(parseXml.getAttributeValue(i).substring(1)), iconDpi, context.getTheme());
            parseXml.close();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
AppAccountParser.java 文件源码 项目:VirtualHook 阅读 39 收藏 0 点赞 0 评论 0
@Override
public Resources getResources(Context context, ApplicationInfo appInfo) throws Exception {
    InstalledAppInfo appSetting = VAppManagerService.get().getInstalledAppInfo(appInfo.packageName, 0);
    if (appSetting != null) {
        AssetManager assets = mirror.android.content.res.AssetManager.ctor.newInstance();
        mirror.android.content.res.AssetManager.addAssetPath.call(assets, appSetting.apkPath);
        Resources hostRes = context.getResources();
        return new Resources(assets, hostRes.getDisplayMetrics(), hostRes.getConfiguration());
    }
    return null;
}
UILabel.java 文件源码 项目:ShangHanLun 阅读 36 收藏 0 点赞 0 评论 0
@Override
public void setTypeface(Typeface tf, int style) {
    //super.setTypeface(tf, style);
    if (!isInEditMode()) {
        String customTypefacePath = REGULAR_FONT_PATH;
        if (style == Typeface.BOLD) {
            customTypefacePath = BOLD_FONT_PATH;
        }

        // load custom font if available on app bundle.
        if (assetExists(getContext(), customTypefacePath)) {
            AssetManager assets = getContext().getAssets();
            tf = Typeface.createFromAsset(assets, customTypefacePath);
        }

        super.setTypeface(tf, style);
    }
}
FileUtils_zm.java 文件源码 项目:exciting-app 阅读 41 收藏 0 点赞 0 评论 0
public boolean copyAssetDirToFiles(Context context, String dirname) {
    try {
        AssetManager assetManager = context.getAssets();
        String[] children = assetManager.list(dirname);
        for (String child : children) {
            child = dirname + '/' + child;
            String[] grandChildren = assetManager.list(child);
            if (0 == grandChildren.length)
                copyAssetFileToFiles(context, child);
            else
                copyAssetDirToFiles(context, child);
        }
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
AOdiaActivity.java 文件源码 项目:AOdia 阅读 41 收藏 0 点赞 0 评论 0
/**
 * sample.oudをdataフォルダにコピーする
 */
private void createSample() {
    File file = new File(getExternalFilesDir(null), "sample.oud");
    if(file.exists()){
        //return;
    }
    try {
        AssetManager assetManager = getAssets();
        ;
        InputStream is = assetManager.open("sample.oud");

        OutputStream os = new FileOutputStream(file);
        byte[] data = new byte[is.available()];
        is.read(data);
        os.write(data);
        is.close();
        os.close();
    } catch (IOException e) {
        Log.w("ExternalStorage", "Error writing " + file, e);
    }
}
FileIO.java 文件源码 项目:phonk 阅读 49 收藏 0 点赞 0 评论 0
public static boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) {
    try {
        String[] files = assetManager.list(fromAssetPath);
        new File(toPath).mkdirs();
        boolean res = true;
        for (String file : files) {
            if (file.contains(".")) {
                res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
            } else {
                res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
            }
        }
        return res;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
MainActivity.java 文件源码 项目:Dynamic 阅读 47 收藏 0 点赞 0 评论 0
protected void loadResources() {
    try {
        AssetManager assetManager = AssetManager.class.newInstance();
        Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
        addAssetPath.invoke(assetManager, dexpath);
        mAssetManager = assetManager;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Resources superRes = super.getResources();
    superRes.getDisplayMetrics();
    superRes.getConfiguration();
    mResources = new Resources(mAssetManager, superRes.getDisplayMetrics(),superRes.getConfiguration());
    mTheme = mResources.newTheme();
    mTheme.setTo(super.getTheme());
}
Convolution2D.java 文件源码 项目:style-transfer 阅读 36 收藏 0 点赞 0 评论 0
public void loadModel(String path) throws IOException {
    mInputStream = mContext.getAssets().open(path + "/W", AssetManager.ACCESS_BUFFER);
    ByteBuffer bb = readInput(mInputStream);
    FloatBuffer.wrap(W).put(bb.asFloatBuffer());

    // padding for GPU BLAS when necessary.
    int W_height_input = in_channels * ksize * ksize;
    if (padded_Y_blas == W_height_input) {
        // If the input width already satisfies the requirement, just copy to the Allocation.
        W_alloc.copyFrom(W);
    } else {
        // If not, a temp allocation needs to be created.
        Allocation input = Allocation.createTyped(mRS,
                Type.createXY(mRS, Element.F32(mRS), W_height_input, out_channels));
        input.copyFrom(W);
        W_alloc.copy2DRangeFrom(0, 0, W_height_input, out_channels, input, 0, 0);
    }

    mInputStream = mContext.getAssets().open(path + "/b", AssetManager.ACCESS_BUFFER);
    bb = readInput(mInputStream);
    FloatBuffer.wrap(b).put(bb.asFloatBuffer());
    b_alloc.copyFrom(b);

    mInputStream.close();
    Log.v(TAG, "Convolution2D loaded: " + b[0]);
}
AssetUtil.java 文件源码 项目:javaide 阅读 46 收藏 0 点赞 0 评论 0
public static boolean copyAssetFolder(AssetManager assetManager,
                                      String fromAssetPath, String toPath) {
    try {
        String[] files = assetManager.list(fromAssetPath);
        new File(toPath).mkdirs();
        boolean res = true;
        for (String file : files)
            if (file.contains(".")) {
                res &= copyAsset(assetManager,
                        fromAssetPath + "/" + file,
                        toPath + "/" + file);
            } else {
                res &= copyAssetFolder(assetManager,
                        fromAssetPath + "/" + file,
                        toPath + "/" + file);
            }
        return res;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
ReactFontManager.java 文件源码 项目:RNLearn_Project1 阅读 47 收藏 0 点赞 0 评论 0
public
@Nullable Typeface getTypeface(
    String fontFamilyName,
    int style,
    AssetManager assetManager) {
  FontFamily fontFamily = mFontCache.get(fontFamilyName);
  if (fontFamily == null) {
    fontFamily = new FontFamily();
    mFontCache.put(fontFamilyName, fontFamily);
  }

  Typeface typeface = fontFamily.getTypeface(style);
  if (typeface == null) {
    typeface = createTypeface(fontFamilyName, style, assetManager);
    if (typeface != null) {
      fontFamily.setTypeface(style, typeface);
    }
  }

  return typeface;
}
CallUtils.java 文件源码 项目:OffIt 阅读 50 收藏 0 点赞 0 评论 0
public static String getJsonFromAssetsPath(AssetManager assetManager, String fileName) {
    String json;
    try {
        InputStream is = assetManager.open(fileName);

        int size = is.available();
        byte[] buffer = new byte[size];

        is.read(buffer);
        is.close();

        json = new String(buffer, "UTF-8");


    } catch (IOException ex) {
        ex.printStackTrace();
        return null;
    }

    return json;
}
HomeRegionFragment.java 文件源码 项目:BilibiliClient 阅读 41 收藏 0 点赞 0 评论 0
private String readAssetJson() {
    AssetManager assetManager = getActivity().getAssets();
    try {
        InputStream in = assetManager.open("region.json");
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuilder builder = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null){
            builder.append(line);
        }
        return builder.toString();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
LocalAssetFetchProducerTest.java 文件源码 项目:GitHub 阅读 42 收藏 0 点赞 0 评论 0
@Test
public void testFetchAssetResource() throws Exception {
  PooledByteBuffer pooledByteBuffer = mock(PooledByteBuffer.class);
  when(mAssetManager.open(eq(TEST_FILENAME), eq(AssetManager.ACCESS_STREAMING)))
      .thenReturn(new ByteArrayInputStream(new byte[TEST_DATA_LENGTH]));
  when(mPooledByteBufferFactory.newByteBuffer(any(InputStream.class), eq(TEST_DATA_LENGTH)))
      .thenReturn(pooledByteBuffer);

  mLocalAssetFetchProducer.produceResults(mConsumer, mProducerContext);
  mExecutor.runUntilIdle();

  assertEquals(
      2,
      mCapturedEncodedImage.getByteBufferRef()
          .getUnderlyingReferenceTestOnly().getRefCountTestOnly());
  assertSame(pooledByteBuffer, mCapturedEncodedImage.getByteBufferRef().get());
  verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
  verify(mProducerListener).onProducerFinishWithSuccess(mRequestId, PRODUCER_NAME, null);
  verify(mProducerListener).onUltimateProducerReached(mRequestId, PRODUCER_NAME, true);
}
HomeRegionFragment.java 文件源码 项目:BilibiliClient 阅读 43 收藏 0 点赞 0 评论 0
/**
 * 读取assets下的json数据
 */
private String readAssetsJson() {

  AssetManager assetManager = getActivity().getAssets();
  try {
    InputStream is = assetManager.open("region.json");
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    StringBuilder stringBuilder = new StringBuilder();
    String str;
    while ((str = br.readLine()) != null) {
      stringBuilder.append(str);
    }
    return stringBuilder.toString();
  } catch (IOException e) {
    e.printStackTrace();
    return null;
  }
}
SplashScene.java 文件源码 项目:Phoenicia 阅读 51 收藏 0 点赞 0 评论 0
public SplashScene(TextureManager textureManager, AssetManager assetManager, VertexBufferObjectManager vbo, Camera camera) {
    super();
    this.setBackground(new Background(new Color(100, 100, 100)));
    try {
        splashTexture = new AssetBitmapTexture(textureManager, assetManager, "textures/splash.png", TextureOptions.BILINEAR);
        splashTextureRegion = TextureRegionFactory.extractFromTexture(splashTexture);
        splashTexture.load();
        splash = new Sprite(0, 0, splashTextureRegion, vbo);

        final float scale_factor = GameActivity.CAMERA_HEIGHT / splashTextureRegion.getHeight();
        splash.setScale(scale_factor+0.1f);
        splash.setPosition((camera.getWidth()) * 0.5f, (camera.getHeight()) * 0.5f);
        this.attachChild(splash);
    } catch (final IOException e) {
        System.err.println("Error loading splash!");
        e.printStackTrace(System.err);
    }
}
songSliderThumb.java 文件源码 项目:Android-Music-Player 阅读 36 收藏 0 点赞 0 评论 0
public Bitmap setImg(String str){
    if(str != null){
        AssetManager assetManager = getContext().getAssets();
        InputStream in;
        byte[] bt = null;
        try {
            in = assetManager.open("imgs/"+str);
            bt = new byte[in.available()];
            in.read(bt);
        } catch (IOException e) {
            e.printStackTrace();
        }
        notBitmap = true;
        Bitmap myBitmap = BitmapFactory.decodeByteArray(bt,0,bt.length);
        Iv.setImageBitmap(myBitmap);
        //Iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return myBitmap;
    }else{
        Iv.setImageBitmap(null);
        return null;
    }
}
PicActivity.java 文件源码 项目:GenericModuleRouter 阅读 46 收藏 0 点赞 0 评论 0
private Bitmap getImageFromAssetsFile(String fileName)
{
    Bitmap image = null;
    AssetManager am = getResources().getAssets();
    try
    {
        InputStream is = am.open(fileName);
        image = BitmapFactory.decodeStream(is);
        is.close();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    return image;
}
SplashActivity.java 文件源码 项目:IslamicLibraryAndroid 阅读 50 收藏 0 点赞 0 评论 0
@Override
protected Boolean doInBackground(Void... voids) {
    SplashActivity activity = activityReference.get();
    StorageUtils.makeIslamicLibraryShamelaDirectory(activity);
    if (activity != null) {
        AssetManager assetManager = activity.getAssets();
        InputStream in;
        try {
            in = assetManager.open(DownloadFileConstants.COMPRESSED_ONLINE_DATABASE_NAME);
            if (!UnZipIntentService.unzip(in,
                    StorageUtils.getIslamicLibraryShamelaBooksDir(activity),
                    this::publishProgress)) {
                throw new IOException("unzip failed for main database");
            }
        } catch (IOException e) {
            Timber.e(e);
            return false;
        }
    }
    return true;
}
FileIO.java 文件源码 项目:phonk 阅读 46 收藏 0 点赞 0 评论 0
public static void copyFileOrDir(Context c, String path) {
    AssetManager assetManager = c.getAssets();
    String assets[] = null;
    try {
        assets = assetManager.list(path);
        if (assets.length == 0) {
            copyFile(c, path);
        } else {
            String fullPath = AppRunnerSettings.getBaseDir() + path;
            File dir = new File(fullPath);
            if (!dir.exists()) {
                dir.mkdir();
            }
            for (String asset : assets) {
                copyFileOrDir(c, path + "/" + asset);
            }
        }
    } catch (IOException ex) {
        Log.e(TAG, ex.toString());
    }
}
App.java 文件源码 项目:mobile-store 阅读 37 收藏 0 点赞 0 评论 0
/**
 * {@link PackageManager} doesn't give us {@code minSdkVersion}, {@code targetSdkVersion},
 * and {@code maxSdkVersion}, so we have to parse it straight from {@code <uses-sdk>} in
 * {@code AndroidManifest.xml}.  If {@code targetSdkVersion} is not set, then it is
 * equal to {@code minSdkVersion}
 *
 * @see <a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a>
 */
private static int[] getMinTargetMaxSdkVersions(Context context, String packageName) {
    int minSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int targetSdkVersion = Apk.SDK_VERSION_MIN_VALUE;
    int maxSdkVersion = Apk.SDK_VERSION_MAX_VALUE;
    try {
        AssetManager am = context.createPackageContext(packageName, 0).getAssets();
        XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
        int eventType = xml.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG && "uses-sdk".equals(xml.getName())) {
                for (int j = 0; j < xml.getAttributeCount(); j++) {
                    if (xml.getAttributeName(j).equals("minSdkVersion")) {
                        minSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("targetSdkVersion")) {
                        targetSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    } else if (xml.getAttributeName(j).equals("maxSdkVersion")) {
                        maxSdkVersion = Integer.parseInt(xml.getAttributeValue(j));
                    }
                }
                break;
            }
            eventType = xml.nextToken();
        }
    } catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
        Log.e(TAG, "Could not get min/max sdk version", e);
    }
    if (targetSdkVersion < minSdkVersion) {
        targetSdkVersion = minSdkVersion;
    }
    return new int[]{minSdkVersion, targetSdkVersion, maxSdkVersion};
}
SeeScoreView.java 文件源码 项目:LiveNotes 阅读 42 收藏 0 点赞 0 评论 0
/**
    * construct the SeeScore scrollable View
    * @param context (usually the MainActivity)
    * @param am the asset manager for font handling
    * @param zn the zoom notification which is called on (pinch) zoom change
    * @param tn the tap notification which is called on a tap in the view with info about what was tapped
 *           if tn == null then taps will not be intercepted and pinch-zoom is enabled
 *           NB tn disables pinch-zoom
    */
public SeeScoreView(Activity context, AssetManager am, ZoomNotification zn, TapNotification tn) {
    super(context);
    setOrientation(VERTICAL);
    this.assetManager = am;
    this.magnification = 1.0F;
    this.zoomNotify = zn;
       this.tapNotify = tn;
    DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
    Display display = context.getWindowManager().getDefaultDisplay();
    display.getMetrics(displayMetrics);
    displayDPI = displayMetrics.densityDpi;
    android.graphics.Point screenSize = new android.graphics.Point();
    display.getSize(screenSize);
    screenHeight = screenSize.y;
}
BlocklyActivityHelper.java 文件源码 项目:Blockly 阅读 45 收藏 0 点赞 0 评论 0
/**
 * Resets the {@link BlockFactory} with the provided block definitions and extensions.
 * @param blockDefinitionsJsonPaths The list of definition asset paths.
 * @throws IllegalStateException On any issues with the input.
 */
public void resetBlockFactory(
        @Nullable List<String> blockDefinitionsJsonPaths) {
    AssetManager assets = mActivity.getAssets();
    BlockFactory factory = mController.getBlockFactory();
    factory.clear();

    String assetPath = null;
    try {
        if (blockDefinitionsJsonPaths != null) {
            for (String path : blockDefinitionsJsonPaths) {
                assetPath = path;
                factory.addJsonDefinitions(assets.open(path));
            }
        }
    } catch (IOException | BlockLoadingException e) {
        throw new IllegalStateException(
                "Failed to load block definition asset file: " + assetPath, e);
    }
}
ScriptBundleUnpackDelegate.java 文件源码 项目:LuaViewPlayground 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 将所有assert下面的脚本解压缩到文件系统
 *
 * @param assetFolderPath
 */
public static void unpackAllAssetScripts(final Context context, final String assetFolderPath) {
    if (context != null && assetFolderPath != null) {
        new SimpleTask1<Object>() {//起simple task 来解压包
            @Override
            protected Object doInBackground(Object[] params) {
                final AssetManager assetManager = context.getAssets();
                if (assetManager != null) {
                    try {
                        final String[] assetBundles = assetManager.list(assetFolderPath);//list 耗时
                        if (assetBundles != null) {
                            for (final String assetBundleFileName : assetBundles) {
                                if (LuaScriptManager.isLuaScriptZip(assetBundleFileName)) {//如果是luaview zip,则解包
                                    unpack(context, FileUtil.removePostfix(assetBundleFileName), assetFolderPath + File.separator + assetBundleFileName);
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                return null;
            }
        }.executeInPool();
    }
}
VideoLiveWallpaper.java 文件源码 项目:LiveWallPaper 阅读 55 收藏 0 点赞 0 评论 0
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
    L.d("VideoEngine#onSurfaceCreated ");
    super.onSurfaceCreated(holder);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setSurface(holder.getSurface());
    try {
        AssetManager assetMg = getApplicationContext().getAssets();
        AssetFileDescriptor fileDescriptor = assetMg.openFd("test1.mp4");
        mMediaPlayer.setDataSource(fileDescriptor.getFileDescriptor(),
                fileDescriptor.getStartOffset(), fileDescriptor.getLength());
        mMediaPlayer.setLooping(true);
        mMediaPlayer.setVolume(0, 0);
        mMediaPlayer.prepare();
        mMediaPlayer.start();

    } catch (IOException e) {
        e.printStackTrace();
    }

}
SampleFileManager.java 文件源码 项目:https-github.com-hyb1996-NoRootScriptDroid 阅读 45 收藏 0 点赞 0 评论 0
public List<SampleGroup> getSamplesFromAssets(AssetManager assets, String path) {
    List<SampleGroup> sampleGroups = new ArrayList<>();
    try {
        String[] groups = assets.list(path);
        for (String groupName : groups) {
            sampleGroups.add(getSampleGroupFromAssets(assets, groupName, path + "/" + groupName));
        }
        return sampleGroups;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
AssetDataSource.java 文件源码 项目:Exoplayer2Radio 阅读 41 收藏 0 点赞 0 评论 0
@Override
public long open(DataSpec dataSpec) throws AssetDataSourceException {
  try {
    uri = dataSpec.uri;
    String path = uri.getPath();
    if (path.startsWith("/android_asset/")) {
      path = path.substring(15);
    } else if (path.startsWith("/")) {
      path = path.substring(1);
    }
    inputStream = assetManager.open(path, AssetManager.ACCESS_RANDOM);
    long skipped = inputStream.skip(dataSpec.position);
    if (skipped < dataSpec.position) {
      // assetManager.open() returns an AssetInputStream, whose skip() implementation only skips
      // fewer bytes than requested if the skip is beyond the end of the asset's data.
      throw new EOFException();
    }
    if (dataSpec.length != C.LENGTH_UNSET) {
      bytesRemaining = dataSpec.length;
    } else {
      bytesRemaining = inputStream.available();
      if (bytesRemaining == Integer.MAX_VALUE) {
        // assetManager.open() returns an AssetInputStream, whose available() implementation
        // returns Integer.MAX_VALUE if the remaining length is greater than (or equal to)
        // Integer.MAX_VALUE. We don't know the true length in this case, so treat as unbounded.
        bytesRemaining = C.LENGTH_UNSET;
      }
    }
  } catch (IOException e) {
    throw new AssetDataSourceException(e);
  }

  opened = true;
  if (listener != null) {
    listener.onTransferStart(this, dataSpec);
  }
  return bytesRemaining;
}
Level5.java 文件源码 项目:blastar 阅读 39 收藏 0 点赞 0 评论 0
public Level5(PlayScreen ps, MainActivity act){

        this.ps = ps;

        try {
            AssetManager assetManager = act.getAssets();
            InputStream inputStream = assetManager.open("maps/map5.jpg");
            map = BitmapFactory.decodeStream(inputStream);
            mapEdge = BitmapFactory.decodeStream(assetManager.open("maps/map5edges.png"));
            inputStream.close();

        }catch(Exception e){
            //dont care sorry
        }
    }
MyApplication.java 文件源码 项目:ClassLoader 阅读 47 收藏 0 点赞 0 评论 0
protected void loadResources() throws InstantiationException, IllegalAccessException, IllegalArgumentException,
        InvocationTargetException, NoSuchMethodException, NoSuchFieldException {
    Log.d(TAG, "MyApplication : loadResources()");
    AssetManager am = (AssetManager) AssetManager.class.newInstance();
    am.getClass().getMethod("addAssetPath", String.class).invoke(am, dexPath);
    mAssetManager = am;
    Constructor<?> constructor_Resources = Resources.class.getConstructor(AssetManager.class, cc.getResources()
            .getDisplayMetrics().getClass(), cc.getResources().getConfiguration().getClass());
    mResources = (Resources) constructor_Resources.newInstance(am, cc.getResources().getDisplayMetrics(), cc.getResources().getConfiguration());
    mTheme = mResources.newTheme();
    mTheme.applyStyle(android.R.style.Theme_Light_NoTitleBar_Fullscreen, true);
}


问题


面经


文章

微信
公众号

扫码关注公众号