Resources & Android Manifest Калин Кадиев Astea Solutions AD
Retrospection: Hello World setContentView(R.layout.main); The only code we see is setContentView(R.layout.main); Where is the “Hello” string? Obviously, go to R.java AUTO-GENERATED FILE. DO NOT MODIFY
Idea: Anything that isn't code should be separated from the code Goal: Easier support of different device configurations Schema: – Put your resources in /res – Android generates R.java compile-time – Access resources via the R.java Application resources
Resource types String: /res/values Drawable: /res/drawable – Simplest case: png, jpg or gif – General concept for a graphic that can be drawn to the screen
Resource types Layout: /res/layout – Defines the architecture for the UI in an Activity or a component of a UI – <RelativeLayout xmlns:android="..." android:layout_width="fill_parent" android:layout_width="fill_parent" android:layout_height="fill_parent" > android:layout_height="fill_parent" > <Button <Button android:layout_width="wrap_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a Button" /> android:text="Hello, I am a Button" /></RelativeLayout>
Resource types Style Menu Animation Others...
Directory qualifiers Screen density: ldpi, mdpi, hdpi, … Orientation: port, land Locale: en, en-US, etc. Platform version: v Screen Size: small, normal, large, xlarge
Resources resolving Android represents unified access to your resources and automatically selects which resource to use, depending on the current device configuration.
Android Manifest Presents essential information about the application to the Android system. Names the application package. The package name serves as a unique identifier for the application. Specifies the versionCode. Used by the market to detect updates.
Android Manifest Describes (not necessarily) application components - activities, services, broadcast receivers, content providers Declares application permissions <uses-permission android:name= "android.permission.ACCESS_FINE_LOCATION"> Declares the minimum API level Lists the libraries linked against
Market filtering Screen size: Device features: Software libraries: Permissions: – If the permission is hardware-oriented and not stated in, the feature is considered required SDK:
Q&A + Feedback Questions? Feedback section: – Did you hear well? – Was there anything you didn’t understand? – What would you like changed in our next lecture?
Further reading Resources Providing resources Supporting multiple screens Android Manifest Market Filtering