android-resources

Which part of Android is in charge of picking a correct resource profile?

我怕爱的太早我们不能终老 提交于 2019-12-01 03:49:19
I have a weird problem. Before you come to an idea to lash out on me, I am working on a custom Jelly Bean. Therefore the "usual nice approaches" might not work here, and dirty workarounds have to be made. I have an APK which contains the following in assets: layout layout-mdpi layout-land layout-large-mdpi layout-large-land-mdpi layout-large-hdpi layout-large-xhdpi And some other metrics code returned this: D/AppDemo( 2091): measured width: 1920 PE width: 1920 scaleFactor = 1.0 D/AppDemo( 2091): [ANDROID] measured width: 1920 measured height: 1080 D/AppDemo( 2091): [ANDROID] scale for

Where to store sensitive global information such as API keys in Android application?

白昼怎懂夜的黑 提交于 2019-12-01 03:49:17
I need to store some sensitive information in an Android application. If I put it in a resource file, it appears that it is trivial for another app to be able to browse and read that file simply by using PackageManager.getResourcesForApplication() . Where is the correct place to put information like this that we don't want people to be able to easily snoop? Should it be in a compiled java file? Or are classfiles also easily readable? Also, if they're in java files, is it possible to reference them from XML files that need them (eg. for the google maps api key)? Your APK will be retrieved from

Adding a bitmap to the drawable resources

寵の児 提交于 2019-12-01 03:17:01
问题 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 ... 回答1: You can't modify that folder once your app is installed. In that case, you must copy the bitmap to a file and access it from there. Take a look at this other question: Save bitmap to location 回答2: The resources are compiled at the apk building time, so you cannot change it in runtime. If you want to have some identifier you can consider

Supporting resources for tablets and mobiles

佐手、 提交于 2019-12-01 01:59:00
问题 I need to support an application for bith mdpi, hdpi and xhdpi mobiles and 7' and 10' tablets I have to admit that I'm a bit lost. So far I only did the tablet version and what I did is : one single folder called "layout" 3 different folders called "drawable-sw600dp", "drawable-sw800dp" and "drawable-sw1200" containing images of 600px large, 800px large and 1200px large. I have the impression that I messed it up and that I should have the created standard "drawable-mdpi", "drawable-hdpi" and

Is it possible to do string substitution in Android resource XML files directly?

回眸只為那壹抹淺笑 提交于 2019-11-30 16:53:04
问题 In my android app, I have a large string resource xml file. I want to make reference and reuse declared resources values within String values. Is it possible to have the R class resolve referenced values (a la @string/db_table_name)? <resources> <string name="db_table_name">tbl_name</string> <string name="ddl">create table @string/tbl_name</string> </resources> Is there a way of doing this. In regular Java world, some tools use ${varname} expression to resolve reference. Can this be done at

Easiest way to know (programmatically) which resources folder is used based on screen density/size

妖精的绣舞 提交于 2019-11-30 14:07:06
Is there a way to know exactly which layout (and other resources) are chosen by Android during runtime based on screen density and size when supporting multiple screens? I need to know the folder's name. EDIT: I need to know the folder's name programmatically . If you're just doing this for debugging purposes, I'd recommend doing something like this: For each qualifier that you have a layout/drawable for, have a values folder with the same qualifier (e.g. if you have a layout-hdpi, also have a values-hdpi to match). Add a strings.xml for each of these folders, and define a string: In values

Use different resources for different application flavors using gradle

╄→尐↘猪︶ㄣ 提交于 2019-11-30 11:28:49
I have an android application and I would like to have different flavors. Specifically I would like to have 2 flavors and for each flavor use different strings (different strings.xml file) and maybe have some icons different. I have tried creating two folders in the project's root folder: flav1 and flav2 and used the following build.gradle android { compileSdkVersion "Google Inc.:Google APIs:15" buildToolsVersion "17.0.0" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res

Obfuscating resource strings that may give away too much information about programming logic

这一生的挚爱 提交于 2019-11-30 10:56:19
I currently use a combination of LVL and Proguard as a first line of defence against piracy. However, what about the resource strings? For example, if there is a resource string like "License check failed" then doesn't the pirate simply need to trace that resource id back to where it was used in the code? In fact, this is also true if the string is something generic like "Please contact dev". What is the best approach? If you define a resource string, you will probably define or use it in: the string resource file res/values/strings.xml , layout files res/layout/*.xml , the generated resource

Android resource selection layout- and values- inconsistencies

心不动则不痛 提交于 2019-11-30 10:25:45
问题 The issue I am experiencing indicates that the resource bucket being selected for a given activity's layout XML is inconsistent with the resources being selected from the values folder despite the exact same resource qualifiers being used in each set of folders. Example After placing some logging code within my application's abstract parent activity I can see that when starting my application over a Nexus 7 type emulator (Android 4.1) the smallest width is indeed 600dp, the layout-sw600dp-*

Get color value programmatically when it's a reference (theme)

雨燕双飞 提交于 2019-11-30 10:14:03
问题 Consider this: styles.xml <style name="BlueTheme" parent="@android:style/Theme.Black.NoTitleBar"> <item name="theme_color">@color/theme_color_blue</item> </style> attrs.xml <attr name="theme_color" format="reference" /> color.xml <color name="theme_color_blue">#ff0071d3</color> So the theme color is referenced by the theme. How can I get the theme_color (reference) programmatically? Normally I would use getResources().getColor() but not in this case because it's referenced! 回答1: This should