android-assets

NullPointerException with custom font from assets

∥☆過路亽.° 提交于 2019-12-08 09:51:00
问题 I'm trying to use custom font in my application, but i got that exception when when run the app: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTypeface(android.graphics.Typeface)' on a null object reference I have a working font and it's in the right path and that's my code: private TextView tv; private Typeface tf; tv = (TextView) findViewById(R.id.wlcText); tf = Typeface.createFromAsset(getAssets(), "en_font.ttf"); tv

Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 04:55:16
问题 Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods Explanation: Right now this program accesses a file from a file manager that takes the selected files path and sets it to the 'mFilename' EditText field. The show PDF button listener below shows the String 'pdffilename' gets assigned the String contained in the 'mFilename' EditText field. The PdfViewerActivity is started and the String 'pdffilename' is passed as an Extra. In the onCreate() the intent

How to parse local JSON file in assets?

﹥>﹥吖頭↗ 提交于 2019-12-07 00:33:13
问题 I have a JSON file in my assets folder. That file has one object with an array. The array has 150+ objects with each having three strings. For each of these 150+ objects I want to extract each string and create a java model object with it passing the three strings. All the tutorials I'm finding on android JSON parsing are fetching the JSON from a url which I don't want to do. 回答1: you should use Gson library as json parser . add this dependency in app gradle file : compile 'com.google.code

Image loaded from assets folder comes in different size than res/drawable

孤人 提交于 2019-12-06 06:09:42
In my project I was loading images dinamically from the folder drawable-hdpi into an ImageSwitcher like this: int[] images = new int[2]; logoImage = (ImageSwitcher) findViewById(R.id.logo_image); images[0] = getResources().getIdentifier(ej.getImagemResource(), "drawable", getPackageName()); images[1] = getResources().getIdentifier(ej.getImagemResolvidaResource(), "drawable", getPackageName()); //... logoImage.setImageResource(images[0]); but for design issues, since it will be like 600 hundred little images 300 x 300 pixels each I decided to put them all into the assets folder and start to

Android “font asset not found” error

一世执手 提交于 2019-12-06 03:23:55
I am developing for Android version 22. I am getting the runtime exception "Font asset not found" Here is the code: Typeface customFont = Typeface.createFromAsset(getAssets(), "fonts/norwester.otf"); And here is my file structure: I am guessing that my file structure is wrong because the "assets" folder does not show up in "Android" mode and only shows up in "Project Mode". What is the problem? Assets folder should be under root directory of main folder which inner folder of src. For Reference Please find attached images of folder structure. I am guessing that my file structure is wrong

Android NDK: read file from assets inside of shared library

落花浮王杯 提交于 2019-12-05 21:59:29
问题 In my app I have to pass a file from assets folder to shared library . I cannot do it with use of jni right now. I'm using precompiled shared library in my project, in which I have hardcoded path to my file, but I'm getting error "No such file or directory" . So in my .apk file I have .so file in libs/armeabi-v7a folder and my file in /assets folder. I have tried to do it like this: char *cert_file = "/assets/cacert.cert"; av_strdup(cert_file); And some other paths, but it doesn't work. Is it

how to get access of android root directory (/system/app) programatically?

五迷三道 提交于 2019-12-05 07:08:52
问题 I have an apk file in asset folder. Now I need to create a program which will install that apk file as system application. Manually it is possible by copying that apk file into sdcard with following steps, $ adb push MyApk.apk /sdcard/ $ adb shell $ su $ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system $ cat /sdcard/MyApk.apk > /system/app/MyApk.apk $ pm install /system/app/MyApk.apk But is it possible to do through code? 回答1: Refer the below code to move user app apk into system

How to access resources (like sound, images etc) directly from native code using Android-NDK?

可紊 提交于 2019-12-05 02:10:26
问题 I want to know that how can I directly access the resources like images, sound files etc. from native code i.e. C++ files. Actually I am looking for any example that could help me to use the asset_manager_jni.h methods. Looking for suggestions. Thanks in advance. With Regards, Atul Prakash Singh 回答1: Well, you have access to stdio.h. So if it's in a known place (say on the SD card), you can just use that as a path. And there's lot's of tutorials on the net about hot to use stdio (fopen,

How to access local assets from a remote URL in Android WebView?

≡放荡痞女 提交于 2019-12-05 01:53:16
问题 To load an asset in HTML, I am using the URL file:///android_asset/my_image.png . It works when I am loading HTML locally, for instance, using a WebView.loadData() method. However, I am unable to load a local asset from a remote web site, for instance, when I load a page using WebView.loadUrl("http://example.com/my_page.html") . It shows the page, but the image is not loaded. How can I fix this problem? UPDATE: tarkeshwar mentioned that it is not possible because of security reasons. I

Use PanoramaApi with custom equirectangular image from Assets folder

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 19:31:28
I have an equirectangular image like this: I have the image in my AssetsFolder, therefor I pass this uri to the Panorama.PanoramaApi.loadPanoramaInfo method: Uri uri = Uri.parse("file:///android_asset/panorama/equi_1.jpg"); Somehow, if I check the result.getViewerIntent, I get null as return value. My gut feeling says this could have to do with the fact that this image is not created with the google camera app, and therefor missing some meta tags, but I'm not sure. The complete code of my PanoramaActivity: public class PanoramaActivity extends Activity implements GoogleApiClient