Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android resource for a specific product

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>
    
like image 572
Luis Daniel Avatar asked Jun 08 '13 02:06

Luis Daniel


People also ask

What is an Android resource?

Overview. In Android, almost everything is a resource. Defining resources that you can then access in your app is an essential part of Android development. Resources are used for anything from defining colors, images, layouts, menus, and string values. The value of this is that nothing is hardcoded.

How do I manage resources in Android?

Resource Manager is a tool window for importing, creating, managing, and using resources in your app. You can open the tool window by selecting View > Tool Windows > Resource Manager from the menu bar or by selecting Resource Manager on the left side bar. Click Add to add a new resource to your project.

What is leveraging Android xml?

XML tags define the data and used to store and organize data. It's easily scalable and simple to develop. In Android, the XML is used to implement UI-related data, and it's a lightweight markup language that doesn't make layout heavy. XML only contains tags, while implementing they need to be just invoked.


1 Answers

  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

like image 73
nandeesh Avatar answered Sep 27 '22 18:09

nandeesh