problem about android-resources-Collection of common programming errors


  • ih8ie8
    java android android-resources
    Normally, I fetch a string value from a resource XML using:String mystring = getResources().getString(R.string.mystring);Now, I would like to select an alternate version of the string based on some runtime condition.String selectivestring; if (someBooleanCondition)selectivestring= getResources().getString(R.string.mystring); else selectivestring= getResources().getString(R.string.theirstring);So far so good, but since I have many such “alternative string pairs”, I would like to methodically pref

  • ErikR
    android android-resources
    In Android app development, it’s often recommended to define constant values as XML resources under res/values. Doing so confers many benefits – app localization is easier to accomplish, device configuration-specific values can be used at runtime, and code is generally cleaner, among other things. My question is, are there cases where this should be avoided, and why?For example, why do<string name=”base_url”>http://api.mycompany.com/</string>rather than simplypublic static final Stri

  • Vikram
    android screen-resolution android-resources android-drawable
    I am developing an app for all the available screen resolutions. My approach is to create different drawable folders and to keep respective images in them. Everything was going fine before I found a clash between two devices of different resolutions. Devices are of 480*800 and 600*1024 resolution. But according to their pixel density they are accessing same drawable folder drawable-hdpi(which is also according to given specification in this image below).My problem is that images in this folder a

  • Rich
    android android-resources
    I’d like to declare some dimensions for naming some common text sizes in my app. Are there any agreed upon standards or recommended best practices for the various res categories? Or, have there been any clever solutions for basing common text sizes dynamically at runtime on the current system default? For example, default text size is considered normal text. A smaller size is declared for minor text/descriptions, a slightly larger size for minor headlines, a much larger size for major headli

  • Jin35
    android android-resources
    Assume I’ve got 2 Application A and B. I want to access resources (drawables, images, strings) of an B application from A application. How would I do that? Edit:You can also designate an Android project as a library project, which allows it to be shared with other projects that depend on it. Once an Android project is designated as a library project, it cannot be installed onto a device.Does it mean That I can not use my library on android market? My aim is to use default resources of Applicati

  • Joe Bowers
    android eclipse ant build android-resources
    I’ve got an Android project that includes references to a library project. The library project contains a resource (a renderscript bytecode package). The main project also has it’s own resources, including a layout, which contains a field that looks like this:<EditText android:id=”@+id/edit_name” />When I build my main project in ant, and I call findViewById(R.id.edit_name) at runtime, the call returns the EditText component I expect. But when I clean the projects and build them in Eclipse

  • Jin35
    android android-resources
    How can I add a Bitmap taken from the web (in the app i mean!) to the drawable resources? So i can access the Bitmap using R.drawable.bitmapName…

  • kape123
    android android-resources
    As explained in Developer documentation Android supports setting different images for different sizes of the screen by putting them in separate folders (drawable-small, drawable-normal, drawable-large and drawable-xlarge).Is it possible to get the “type” of the screen that Android is using to load the resources during runtime? I need to log this variable for error reporting and it would help a lot if I can tell which drawable type folder system is using (similarly to how I can tell if it is ldpi

  • rgrocha
    android android-resources
    I have an android app which has 3 languages in res folder. English French ChineseI want my app to add another language at runtime in res folder and not by adding string xml files and recompile them.How can i achieve this? I’ve search alot in google and no luck.Thanks alot!!

  • Darnst
    android locale android-resources
    I am introducing a second language (French) into my App. I have had the strings.xml resource file translated and created a new folder called values-fr, etc… The French strings are coming through fine in the UI apart from one part of the app. There’s a help section which is currently stored in the SQLite db and the DatabaseHelper code reads from Strings.xml by referencing string resources, e.g. context.getString(R.string.tip1title);One option I’m considering is adding a “LANGUAGE” column to

  • Alex
    android android-layout android-resources
    I’ve search everywhere and can’t find any way of doing this at all:In my project, I have two resources folders for layouts: One is called “layout”, and the other is called “layout-land”. This is the familiar way of having two separate layouts for each Activity that get used depending on the current orientation. The issue is that I don’t have separate “layout-land” layouts for every Activity, and not all Activities even need a different layout for landscape mode. What I’ve done is overridden t

  • Jin35
    android android-location android-resources
    I have application with internet access and don’t want to store many string.xml files for different languages.What I want:Application contains only one string.xml with english strings. When user launches it – I see user’s phone locale, and ask my own server for necessary language file. (resource keys will be the same) When new resource file comes, all interface should work with new file.The question is how to change existing or add new string.xml file in runtime?

  • Glenn85
    android android-resources
    In my app I support three different DPIs (MDPI, HDPI, XHDPI). On all of my test devices the app works just fine, except for the Galaxy Nexus (XHDPI) and Xperia Z (XXHDPI).When the app starts everything looks fine and well on these devices, but when a certain new Activity starts it suddenly uses the MDPI resources.Is this behavior that anyone recognizes or have a solution for this? Please let me know!I already played with android:launchMode, unfortunately without any success…

  • Swayam
    java android eclipse android-resources
    Sometimes, when I want to refer a value to a string reference I use @string/blabla, but sometimes, it gives me an error that I can run the code unless i change @string to @+string What’s the difference between them? Any answer would be so helpful. Thanks in Advance!

  • darkravedev
    android inputstream android-resources
    Last night my code was working fine, today when I load it up, the raw resource I access in my code is trying to read from an id pointing to a string rather than an xml file in my raw folder.I have used http://www.statman.info/conversions/hexadecimal.html to track the resource id’s and match them to their R hex id’s and I can SEE that it should be accessing 0x7f040002 but is accessing 7f060000 for some reason…I have already looked at : Accessing wrong raw resource in AndroidI have done all of t

  • Varun Tewari
    android performance android-resources android-memory
    A lot of blogs and best practices for Android Development says “You don’t need to supply bitmaps for every possible density, Android will scale your bitmaps (typically when they are loaded) to match the current density.”Reference Link : https://plus.google.com/105051985738280261832/posts/6eWwQvFGLV8I tried it works well. But i couldn’t understand one thing.For instance i created a sample app with 5 full screen images of around 1.5 MB each in a view pager.I created heavy images for 7 inch MDPI de

  • ASP
    android android-resources decompiling android-apk
    The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months (I know I am an idiot for not backing it up) All I have is the APK file that is stored in my email from when I sent it to a friend. My question is: Is there any way to extract my source code from this APK file? I realize that is is most likely a shot in the dark… but I am really desperate.I have read about tools like smali and apktool… could these be of help?

  • Stochastically
    android android-resources android-drawable android-memory
    Originally everything was fine. I had been working with the 5 drawable directoriesdrawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi drawable-xxhdpithat were created for me by the eclipse adt-bundle when I created a new project recently. So when I needed a new bitmap, I had been putting a copy of the bitmap into each of these 5 directories. This always seemed a bit strange to me, so I was happy to discover by reading the Android documentation Providing Resources that I could have a sing

  • Justin Livi
    android flash admob android-resources air-native-extension
    I’m creating an AIR native extension to integrate AdMob.I’ve followed the guidelines for using external resources described here: http://www.adobe.com/devnet/air/articles/ane-android-devices.htmland packaged google’s adMob jar in my native extension jar as described here: AIR 3 Native Extensions for Android – Can I/How to include 3rd party libraries?I have a NewAdFunction class which implements FREFunction and is called by the actionscript side. The NewAdFunction.call() function contains essenti

  • Mate Krizanac
    android xml android-layout android-resources
    Here is my problem , i created app for android and was always testing it on my phone with 480×800 dimensions, and app works great, in landscape and portrait mode. I used relative layout cause it seemed like the best good solution for a beginner like me. But now, i tried installing app on smaller device (lg optimus l3) and add is covering my buttons, landscape mode not showing buttons at all .. i used density independent pixels for sizes of every aspect of layout but still it doesn’t work . . an

  • Ehsan Shirzadi
    android constructor android-resources
    I have a class constructor. inside that I want to use string resources using getResources. when I want to run the app it produces an error tells “Unfortunately myProject has stopped”.public EhsanAdapter(Context c) {context = c;size = 5;list = new ArrayList<SingleRow>();Resources res = c.getResources();}What’s wrong with this? when I comment the line with getresource command, I have no error.This is whole class:package com.example.listviewba;import java.util.ArrayList;import android.content

  • Sergey Glotov
    android android-4.0 android-resources
    I have developed an app on Android target version 4.1.After rotating string resources in application, show as white square. Application don’t crashed.This happened after activity execute work with biggest heap size .It works fine in Android 3.2 tablet.

  • user1489886
    android file text context android-resources
    I’m trying for a while to make android read from a text file that I already have in the R.raw folder.I have the function void readfile(Context context) that contains the line InputStream is = context.getResources().openRawResource(R.raw.data);However when I try to run the app it crashes at that exact line. Can you tell me a workaround? Or another way to read from that file?

  • Glaedr
    android android-resources
    I want to include a resources xml file to my Android application project to hold some string values intended to have a specific purpose, named categories_names.xml, copying it into the res/values folder, but as soon as I try to run the application it exits throwing an InflateException. Strange thing is, this resources file is not even accessed from within the launcher activity. How is it possible? I report the backtrace below.07-13 13:24:21.842: W/dalvikvm(27215): threadid=1: thread exiting with

  • Poonam Anthony
    android android-resources
    I’m trying to parse an xml file and extract data from it to display in my android app. The xml file is as follows:<?xml version=”1.0″ encoding=”UTF-8″?> <record> <study id=”1″><topic>SAX Parser</topic><content>Learn how to parse XML using SAXParser</content><author>Pete Houston</author><date>02-Oct-2011</date> </study>The file is stored in res/raw folder. The android activity calls a function which tries to read the xml fil

  • Jin35
    android android-listview android-resources
    I am getting an exception but could not get where exactly the exception occured. I searched but could not get the my project name in the stacktrace.Below is my stacktrace02-13 15:48:23.741: W/dalvikvm(416): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 02-13 15:48:24.026: W/System.err(416): android.content.res.Resources$NotFoundException: File from xml type layout resource ID #0x102000a 02-13 15:48:24.036: W/System.err(416): at android.content.res.Resources.loadXml

  • Mike Chung
    android android-manifest android-resources
    I have been searching stack and have found no help regarding this topic03-06 11:37:02.448: W/ResourceType(14147): No package identifier when getting value for resource number 0x0000000a 03-06 11:37:02.448: D/AndroidRuntime(14147): Shutting down VM 03-06 11:37:02.448: W/dalvikvm(14147): threadid=1: thread exiting with uncaught exception (group=0x41d1b438) 03-06 11:37:02.448: I/Process(14147): Sending signal. PID: 14147 SIG: 9 03-06 11:37:02.448: E/AndroidRuntime(14147): FATAL EXCEPTION: mai

  • iDroid Explorer
    android android-resources android-4.0 navigation-drawer
    I am going to implement the Navigation Drawer in my application. I come with the sample demo of the Developer site for same. Here is the link of original Demo.I have download that demo and it works fine. But now if i am going to run that in to the Android 2.3.5 then it get crashed. Its not working there. I have also Try with to add library of ActionBarSherlock in to project and try that But now i am getting recource error like below:06-28 10:14:43.500: E/AndroidRuntime(18988): android.view.Infla

  • Class Stacker
    android android-resources android-compatibility android-lint
    It appears the best way to develop an Android application today is to target android-17 in project.properties along with minSdkVersion “whateversuitsyou” and targetSdkVersion 17 in the manifest.In this configuration, the standard lint checks will notify about any API calls which are only available in API versions above “whateversuitsyou” and one can use reflection etc to dynamically support the newer features, if any.However, in this setup, at least without further configuration, it is possible

Web site is in building