AssetManager open - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AssetManager open method.

This code example shows how to use the following methods:open
		final BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
		decodeOptions.inJustDecodeBounds = true;
 
		InputStream in = null;
		try { 
			in = pAssetManager.open(pAssetPath);
			BitmapFactory.decodeStream(in, null, decodeOptions);
		} catch (final IOException e) {
			Debug.e("Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: " + pAssetPath, e);
		} finally { 
			StreamUtils.close(in);
		} 
 
		return new AssetBitmapTextureAtlasSource(pAssetManager, pAssetPath, pTextureX, pTextureY, decodeOptions.outWidth, decodeOptions.outHeight);
	} 
 
	AssetBitmapTextureAtlasSource(final AssetManager pAssetManager, final String pAssetPath, final int pTextureX, final int pTextureY, final int pTextureWidth, final int pTextureHeight) {
		super(pTextureX, pTextureY, pTextureWidth, pTextureHeight);
 
		this.mAssetManager = pAssetManager;
6
CodeRank
This code example shows how to use the following methods:open
    private static ArrayList<String> fontPaths = new ArrayList<String>();
 
    @Implementation 
    public static Typeface createFromAsset(AssetManager assetManager, String path) {
        try { 
            assetManager.open(path);
            Typeface typeface = Robolectric.newInstanceOf(Typeface.class);
            shadowOf(typeface).setAssetPath(path);
            return typeface;
        } catch (IOException e) {
            throw new RuntimeException("Font not found");
        } 
    } 
 
    @Implementation 
    public static Typeface createFromFile(String path) {
        if (fontPaths.contains(path)) {
            Typeface typeface = Robolectric.newInstanceOf(Typeface.class);
            shadowOf(typeface).setAssetPath(path);
            return typeface;
7
CodeRank
This code example shows how to use the following methods:open
	// Methods 
	// =========================================================== 
 
	public TMXTileSet loadFromAsset(final int pFirstGlobalTileID, final String pAssetPath) throws TSXLoadException {
		try { 
			return this.load(pFirstGlobalTileID, this.mAssetManager.open(pAssetPath));
		} catch (final IOException e) {
			throw new TSXLoadException("Could not load TMXTileSet from asset: " + pAssetPath, e);
		} 
	} 
 
	private TMXTileSet load(final int pFirstGlobalTileID, final InputStream pInputStream) throws TSXLoadException {
		try{ 
			final SAXParserFactory spf = SAXParserFactory.newInstance();
			final SAXParser sp = spf.newSAXParser();
 
			final XMLReader xr = sp.getXMLReader();
			final TSXParser tsxParser = new TSXParser(this.mAssetManager, this.mTextureManager, this.mTextureOptions, pFirstGlobalTileID);
			xr.setContentHandler(tsxParser);
 

7
CodeRank
This code example shows how to use the following methods:open
		} 
	} 
	 
	public static Bitmap readBitmap(AssetManager manager, String name) {
		try { 
			return readBitmap(manager.open(name));
		} catch (IOException e) {
			AphidLog.e(e, "Failed to read bitmap '%s' from assets", name);
			return null; 
		} 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:open, openFd
This code example shows how to use the following methods:open
	// Methods 
	// =========================================================== 
 
	public TexturePack loadFromAsset(final AssetManager pAssetManager, final String pAssetPath) throws TexturePackParseException {
		try { 
			return this.load(pAssetManager, pAssetManager.open(this.mAssetBasePath + pAssetPath));
		} catch (final IOException e) {
			throw new TexturePackParseException("Could not load " + this.getClass().getSimpleName() + " data from asset: " + pAssetPath, e);
		} 
	} 
 
	public TexturePack load(final AssetManager pAssetManager, final InputStream pInputStream) throws TexturePackParseException {
		try{ 
			final SAXParserFactory spf = SAXParserFactory.newInstance();
			final SAXParser sp = spf.newSAXParser();
 
			final XMLReader xr = sp.getXMLReader();
			final TexturePackParser texturePackerParser = new AssetTexturePackParser(this.mTextureManager, pAssetManager, this.mAssetBasePath);
			xr.setContentHandler(texturePackerParser);
 

7
CodeRank
This code example shows how to use the following methods:open
        Resources resources = context.getResources();
        AssetManager assetManager = resources.getAssets();
 
        // Read from the /assets directory 
        try { 
            InputStream inputStream = assetManager.open(name);
            Properties properties = new Properties();
            properties.load(inputStream);
            return properties;
        } catch (IOException e) {
            Log.e("Gibberbot", "exception reading properties", e);
            return null; 
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:open
 
	public static InputStream openInPackage(String path)
	{ 
		try { 
			//Log.d(TAG, "Open " + path + "..."); 
			InputStream is = am.open(path, AssetManager.ACCESS_RANDOM);
			is.mark(MAX_SIZE);
			return is;
		} 
		catch (IOException e) {
			Log.e(TAG, e.getMessage());
			return null; 
		} 
	} 
	 
	public static void close(InputStream is)
	{ 
		try { 
			if (is == null)
				return; 
6
CodeRank
This code example shows how to use the following methods:open
		Context ctx = getContext();
		 
		TestUtil.extractKey(ctx, keyAsset, "/sdcard/key");
		 
		AssetManager am = ctx.getAssets();
		InputStream is = am.open(dbAsset, AssetManager.ACCESS_STREAMING);
		 
		ImporterV3 importer = new ImporterV3();
		importer.openDatabase(is, password, "/sdcard/key");
		 
		is.close();
	} 
	 
	public void testXMLKeyFile() throws Exception { 
		testKeyfile("kdb_with_xml_keyfile.kdb", "keyfile.key", "12345"); 
	} 
	 
	public void testBinary64KeyFile() throws Exception { 
		testKeyfile("binary-key.kdb", "binary.key", "12345"); 
	} 
6
CodeRank
This code example shows how to use the following methods:open
 
	public void testComposite() throws IOException, InvalidDBException { 
		Context ctx = getContext();
		 
		AssetManager am = ctx.getAssets();
		InputStream is = am.open("keyfile.kdbx", AssetManager.ACCESS_STREAMING);
		 
		ImporterV4 importer = new ImporterV4();
		importer.openDatabase(is, "12345", "/sdcard/key");
		 
		is.close();
		 
	} 
	 
	public void testKeyfile() throws IOException, InvalidDBException { 
		Context ctx = getContext();
		 
		AssetManager am = ctx.getAssets();
		InputStream is = am.open("key-only.kdbx", AssetManager.ACCESS_STREAMING);
		 
6
CodeRank

Related AssetManager open Questions & Answers:

open Method Overview
Open an asset using ACCESS_STREAMING mode.
See Code Examples for other Android AssetManager Methods: