android Programming Glossary: context.getassets
Set font for all textViews in activity? http://stackoverflow.com/questions/10766716/set-font-for-all-textviews-in-activity TextView TextView v .setTypeface Typeface.createFromAsset context.getAssets font.ttf catch Exception e Solution2 you can subclass the..
Android: Playing an Asset Sound Using WebView http://stackoverflow.com/questions/10966245/android-playing-an-asset-sound-using-webview .mp3 mp new MediaPlayer try AssetFileDescriptor afd context.getAssets .openFd url mp.setDataSource afd.getFileDescriptor afd.getStartOffset.. Log.i MyWebViewClient url try AssetFileDescriptor afd context.getAssets .openFd url mp new MediaPlayer mp.setDataSource afd.getFileDescriptor.. ... get your assets as follows... AssetFileDescriptor afd context.getAssets .openFd url In your MainActivity set the WebViewClient by passing..
Custom font for Android listview http://stackoverflow.com/questions/15293437/custom-font-for-android-listview context this.data data tf Typeface.createFromAsset context.getAssets FONT Put the font you want to use in your assets folder and..
Access a typeface once from asset and use it as a reference http://stackoverflow.com/questions/18847531/access-a-typeface-once-from-asset-and-use-it-as-a-reference private Typeface titleFont Typeface.createFromAsset context.getAssets fonts InterstateCondMonoLgt.ttf private Typeface contentFont.. private Typeface contentFont Typeface.createFromAsset context.getAssets fonts InterstateLight.ttf TextView txtMain TextView view.findViewById.. if mTitleFont null mTitleFont Typeface.createFromAsset context.getAssets fonts typefaceName typeFace mTitleFont else if typefaceName.equals..
How to use my own sqlite database? http://stackoverflow.com/questions/2387421/how-to-use-my-own-sqlite-database Open your local db as the input stream InputStream myInput context.getAssets .open DB_NAME Open the empty db as the output stream OutputStream..
Android how to get access to raw resources that i put in res folder? http://stackoverflow.com/questions/2856407/android-how-to-get-access-to-raw-resources-that-i-put-in-res-folder resources share improve this question InputStream raw context.getAssets .open filename.ext Reader is new BufferedReader new InputStreamReader..
How to load a Java class dynamically on android/dalvik? http://stackoverflow.com/questions/3022454/how-to-load-a-java-class-dynamically-on-android-dalvik InputStream in int len byte data new byte 2048 try in context.getAssets .open f.dex len in.read data in.close DexFile d Class c..
Android Dev Help: Saving an image from Res/raw or Asset folder to the Sd card http://stackoverflow.com/questions/4509877/android-dev-help-saving-an-image-from-res-raw-or-asset-folder-to-the-sd-card android share improve this question InputStream is context.getAssets .open fileName OutputStream os new FileOutputStream Environment.getExternalStorageDirectory..
Is it possible to run a native arm binary on a non-rooted android phone? http://stackoverflow.com/questions/4703131/is-it-possible-to-run-a-native-arm-binary-on-a-non-rooted-android-phone String localPath Context context try InputStream in context.getAssets .open assetPath FileOutputStream out new FileOutputStream localPath..
Sqlite issues with HTC Desire HD http://stackoverflow.com/questions/4718934/sqlite-issues-with-htc-desire-hd dbAsset asset_dir dbName .sqlite InputStream myInput context.getAssets .open dbAsset Context.MODE_PRIVATE Create a file in the app's..
Reading a simple text file http://stackoverflow.com/questions/5771366/reading-a-simple-text-file Use AssetManager class to access it. AssetManager am context.getAssets InputStream is am.open test.txt Or you can also put the file..
Android Camera will not work. startPreview fails http://stackoverflow.com/questions/7942378/android-camera-will-not-work-startpreview-fails String path throws IOException AssetManager assetManager context.getAssets InputStream stream assetManager.open path try return new Scanner..
How to support Arabic text in Android? http://stackoverflow.com/questions/7962704/how-to-support-arabic-text-in-android if typeface null typeface Typeface.createFromAsset context.getAssets DroidSansFallback.ttf TAHOMA.TTF return typeface 3 And in..
How to make custom textview? http://stackoverflow.com/questions/9477336/how-to-make-custom-textview super context Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face public FontTextView.. super context attrs Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face public FontTextView.. attrs defStyle Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face protected void onDraw..
Set font for all textViews in activity? http://stackoverflow.com/questions/10766716/set-font-for-all-textviews-in-activity i overrideFonts context child else if v instanceof TextView TextView v .setTypeface Typeface.createFromAsset context.getAssets font.ttf catch Exception e Solution2 you can subclass the TextView class with your custom font and use it instead of textview...
Android: Playing an Asset Sound Using WebView http://stackoverflow.com/questions/10966245/android-playing-an-asset-sound-using-webview WebView view String url if url.endsWith .mp3 mp new MediaPlayer try AssetFileDescriptor afd context.getAssets .openFd url mp.setDataSource afd.getFileDescriptor afd.getStartOffset afd.getLength afd.close mp.prepare mp.start catch.. url.endsWith .mp3 url url.replace file android_asset webpages Log.i MyWebViewClient url try AssetFileDescriptor afd context.getAssets .openFd url mp new MediaPlayer mp.setDataSource afd.getFileDescriptor afd.getStartOffset afd.getLength afd.close mp.prepare.. this.context context Then in shouldOverrideUrlLoading ... get your assets as follows... AssetFileDescriptor afd context.getAssets .openFd url In your MainActivity set the WebViewClient by passing this which is the Activity Context as follows... webMain.setWebViewClient..
Custom font for Android listview http://stackoverflow.com/questions/15293437/custom-font-for-android-listview data this.layoutResourceId layoutResourceId this.context context this.data data tf Typeface.createFromAsset context.getAssets FONT Put the font you want to use in your assets folder and fill your listview like this listAdapter new CustomAdapter this..
Access a typeface once from asset and use it as a reference http://stackoverflow.com/questions/18847531/access-a-typeface-once-from-asset-and-use-it-as-a-reference txtTitle.setTypeface titleFont txtTitle.setText result.getTitle private Typeface titleFont Typeface.createFromAsset context.getAssets fonts InterstateCondMonoLgt.ttf private Typeface contentFont Typeface.createFromAsset context.getAssets fonts InterstateLight.ttf.. context.getAssets fonts InterstateCondMonoLgt.ttf private Typeface contentFont Typeface.createFromAsset context.getAssets fonts InterstateLight.ttf TextView txtMain TextView view.findViewById R.id.main txtMain.setTypeface contentFont txtMain.setText.. null try if typefaceName.equals FontType.TITLE_FONT.toString if mTitleFont null mTitleFont Typeface.createFromAsset context.getAssets fonts typefaceName typeFace mTitleFont else if typefaceName.equals FontType.CONTENT_FONT.toString if mContentFont null..
How to use my own sqlite database? http://stackoverflow.com/questions/2387421/how-to-use-my-own-sqlite-database if doUpgrade dbFile.delete createDb true if createDb Open your local db as the input stream InputStream myInput context.getAssets .open DB_NAME Open the empty db as the output stream OutputStream myOutput new FileOutputStream dbFile transfer bytes..
Android how to get access to raw resources that i put in res folder? http://stackoverflow.com/questions/2856407/android-how-to-get-access-to-raw-resources-that-i-put-in-res-folder
How to load a Java class dynamically on android/dalvik? http://stackoverflow.com/questions/3022454/how-to-load-a-java-class-dynamically-on-android-dalvik test function I wrote was this public void testLoader InputStream in int len byte data new byte 2048 try in context.getAssets .open f.dex len in.read data in.close DexFile d Class c defineClass net.webvm.FooImpl data 0 len Foo foo Foo c.newInstance..
Android Dev Help: Saving an image from Res/raw or Asset folder to the Sd card http://stackoverflow.com/questions/4509877/android-dev-help-saving-an-image-from-res-raw-or-asset-folder-to-the-sd-card e.printStackTrace Log.i filepath filepath return filepath android share improve this question InputStream is context.getAssets .open fileName OutputStream os new FileOutputStream Environment.getExternalStorageDirectory File.separator fileName BufferedInputStream..
Is it possible to run a native arm binary on a non-rooted android phone? http://stackoverflow.com/questions/4703131/is-it-possible-to-run-a-native-arm-binary-on-a-non-rooted-android-phone can do this like so private static void copyFile String assetPath String localPath Context context try InputStream in context.getAssets .open assetPath FileOutputStream out new FileOutputStream localPath int read byte buffer new byte 4096 while read in.read..
Sqlite issues with HTC Desire HD http://stackoverflow.com/questions/4718934/sqlite-issues-with-htc-desire-hd The name of the database to use from the bundled assets. String dbAsset asset_dir dbName .sqlite InputStream myInput context.getAssets .open dbAsset Context.MODE_PRIVATE Create a file in the app's file directory since sqlite requires a path Not ideal but..
Reading a simple text file http://stackoverflow.com/questions/5771366/reading-a-simple-text-file your text file in the assets directory under the Android project. Use AssetManager class to access it. AssetManager am context.getAssets InputStream is am.open test.txt Or you can also put the file in the res raw directory where the file will be indexed and..
Android Camera will not work. startPreview fails http://stackoverflow.com/questions/7942378/android-camera-will-not-work-startpreview-fails to read the first coordinate private static String readFile String path throws IOException AssetManager assetManager context.getAssets InputStream stream assetManager.open path try return new Scanner stream .useDelimiter A .next finally stream.close private..
How to support Arabic text in Android? http://stackoverflow.com/questions/7962704/how-to-support-arabic-text-in-android typeface public static final Typeface GetFarsiFont Context context if typeface null typeface Typeface.createFromAsset context.getAssets DroidSansFallback.ttf TAHOMA.TTF return typeface 3 And in your Activity Typeface tf Farsi.GetFarsiFont this MyTextView.setTypeface..
How to make custom textview? http://stackoverflow.com/questions/9477336/how-to-make-custom-textview FontTextView extends TextView public FontTextView Context context super context Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face public FontTextView Context context AttributeSet attrs super context attrs Typeface.. face public FontTextView Context context AttributeSet attrs super context attrs Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face public FontTextView Context context AttributeSet attrs int defStyle super context.. Context context AttributeSet attrs int defStyle super context attrs defStyle Typeface face Typeface.createFromAsset context.getAssets Helvetica_Neue.ttf this.setTypeface face protected void onDraw Canvas canvas super.onDraw canvas and in xml com.util.FontTextView..
|