12

i got this code from Settings app...

<string name="about_settings" product="tablet">About tablet</string>
<string name="about_settings" product="default">About phone</string>

then my questions are:

  1. from where at runtime the system load the correct string resource ?
  2. What must I do to add a new product? e.g.

    <string name="about_settings" product="laptop">About laptop</string>
    
Luis Daniel
  • 687
  • 7
  • 18

2 Answers2

12
  1. from where at runtime the system load the correct string resource ?

The system does not load this at runtime. The correct string resource is preloaded according to PRODUCT_CHARACTERISTICS defined for a specific target build. So you cannot use this while building from eclipse. This is used only for building apps preloaded on platform.

2 . What must I do to add a new product? e.g.

You need to add to PRODUCT_CHARACTERISTICS in device.mk file

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
nandeesh
  • 24,740
  • 6
  • 69
  • 79
  • Was looking through source and stumbled on the same thing. Out of curiosity, where did you learn the origins of this `product` attribute? From working on custom ROMs? I assume that's where you would preload apps. – Tony Chan Oct 12 '13 at 01:15
-1

Answer for your question 1.
You can get them via

String mystring = getResources().getString(R.string.mystring);

But your strings.xml should something like this

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="tablet" >About tablet</string>
    <string name="default" >About phone</string>
 </resources>

Answer for your question 2.
How will that work, because that is a resource file. If you want you can either create a file and save the information in it. Locally. But it will be only on that device.

MDMalik
  • 3,951
  • 2
  • 25
  • 39
  • Your answer for the question 1 is not what i need, from my previous example i guess that the value for the attribute 'product' is compared with the value stored on /sys/class/dmi/id/uevent and then is selected the right resource. – Luis Daniel Jun 08 '13 at 03:35