Wednesday 28 December 2011

What is Run Android Lint Checks and What are it's Advantages.

For First To Get Advantage for Run Android lint for your Android Project You May Need To Download
Eclipse With Latest Update as Well Android ADT Plugins 16 For use of Lint in Eclipse with out Command Line .

First if you are Using Old Eclipse Like Eclipse Galileo (3.5)  and Eclipse Helios (3.6) Then i Prefer You to Use Latest Eclipse Which you can Download From www.Eclipse.org   Click Here is Link http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigosr1

After Getting Eclipse Version 3.7 you can Setup Android Application Development Environment By Getting Guide From Below Link:

http://developer.android.com/sdk/installing.html


Check Requirement From Below Link :

http://developer.android.com/sdk/requirements.html

ok now when you Done Will Eclipse Indigo and Set up ADT 16 Plugin and Your Android SDK with it You can see One new Tool in Eclipse that it Run Android lint .Now Let see What is Run Android Lint.



Android Lint is a new tool for ADT 16 (and Tools 16) which scans Android project sources for potential bugs. It is available both as a command line tool, as well as integrated with Eclipse. The architecture is deliberately IDE independent so it will hopefully be integrated with other IDEs, with other build tools and with continuous integration systems as well.

Here are some examples of the types of errors that it looks for:

  • Missing translations (and unused translations)
  • Layout performance problems (all the issues the old layoutopt tool used to find, and more)
  • Unused resources
  • Inconsistent array sizes (when arrays are defined in multiple configurations)
  • Accessibility and internationalization problems (hardcoded strings, missing contentDescription, etc)
  • Icon problems (like missing densities, duplicate icons, wrong sizes, etc)
  • Usability problems (like not specifying an input type on a text field)
  • Manifest errors
and many more.

Now Here Are Some Advantages You Will Get to Known When You Run Android Lint for You Android Project .Here are lint Checks .


$ lint --show
Available issues:

Correctness
===========

AdapterViewChildren
-------------------
Summary: Checks that AdapterViews do not define their children in XML

Priority: 10 / 10
Severity: Warning
Category: Correctness

AdapterViews such as ListViews must be configured with data from Java code,
such as a ListAdapter.


More information: 
http://developer.android.com/reference/android/widget/AdapterView.html
MissingPrefix
-------------
Summary: Detect XML attributes not using the Android namespace

Priority: 8 / 10
Severity: Warning
Category: Correctness

Most Android views have attributes in the Android namespace. When referencing
these attributes you *must* include the namespace prefix, or your attribute
will be interpreted by aapt as just a custom attribute.


MissingTranslation
------------------
Summary: Checks for incomplete translations where not all strings are
translated

Priority: 8 / 10
Severity: Error
Category: Correctness

If an application has more than one locale, then all the strings declared in
one language should also be translated in all other languages.

By default this detector allows regions of a language to just provide a subset
of the strings and fall back to the standard language strings. You can require
all regions to provide a full translation by setting the environment variable
ANDROID_LINT_COMPLETE_REGIONS.


Proguard
--------
Summary: Looks for problems in proguard.cfg files

Priority: 8 / 10
Severity: Error
Category: Correctness

Using -keepclasseswithmembernames in a proguard.cfg file is not correct; it
can cause some symbols to be renamed which should not be.
Earlier versions of ADT used to create proguard.cfg files with the wrong
format. Instead of -keepclasseswithmembernames use -keepclasseswithmembers,
since the old flags also implies "allow shrinking" which means symbols only
referred to from XML and not Java (such as possibly CustomViews) can get
deleted.


More information: http://code.google.com/p/android/issues/detail?id=16384

ScrollViewCount
---------------
Summary: Checks that ScrollViews have exactly one child widget

Priority: 8 / 10
Severity: Warning
Category: Correctness

ScrollViews can only have one child widget. If you want more children, wrap
them in a container layout.


DuplicateIds
------------
Summary: Checks for duplicate ids within a single layout

Priority: 7 / 10
Severity: Warning
Category: Correctness

Within a layout, id's should be unique since otherwise findViewById() can
return an unexpected view.


InconsistentArrays
------------------
Summary: Checks for inconsistencies in the number of elements in arrays

Priority: 7 / 10
Severity: Warning
Category: Correctness

When an array is translated in a different locale, it should normally have the
same number of elements as the original array. When adding or removing
elements to an array, it is easy to forget to update all the locales, and this
lint warning finds inconsistencies like these.

Note however that there may be cases where you really want to declare a
different number of array items in each configuration (for example where the
array represents available options, and those options differ for different
layout orientations and so on), so use your own judgement to decide if this is
really an error.

You can suppress this error type if it finds false errors in your project.


NestedScrolling
---------------
Summary: Checks whether a scrolling widget has any nested scrolling widgets
within

Priority: 7 / 10
Severity: Warning
Category: Correctness

A scrolling widget such as a ScrollView should not contain any nested
scrolling widgets since this has various usability issues


ScrollViewSize
--------------
Summary: Checks that ScrollViews use wrap_content in scrolling dimension

Priority: 7 / 10
Severity: Warning
Category: Correctness

ScrollView children must set their layout_width or layout_height attributes to
wrap_content rather than fill_parent or match_parent in the scrolling
dimension


DuplicateIncludedIds
--------------------
Summary: Checks for duplicate ids across layouts that are combined with
include tags

Priority: 6 / 10
Severity: Warning
Category: Correctness

It's okay for two independent layouts to use the same ids. However, if layouts
are combined with include tags, then the id's need to be unique within any
chain of included layouts, or Activity#findViewById() can return an unexpected
view.


ExtraTranslation
----------------
Summary: Checks for translations that appear to be unused (no default language
string)

Priority: 6 / 10
Severity: Warning
Category: Correctness

If a string appears in a specific language translation file, but there is no
corresponding string in the default locale, then this string is probably
unused. (It's technically possible that your application is only intended to
run in a specific locale, but it's still a good idea to provide a fallback.)


ManifestOrder
-------------
Summary: Checks for manifest problems like <uses-sdk> after the <application>
tag

Priority: 5 / 10
Severity: Warning
Category: Correctness

The <application> tag should appear after the elements which declare which
version you need, which features you need, which libraries you need, and so
on. In the past there have been subtle bugs (such as themes not getting
applied correctly) when the <application> tag appears before some of these
other elements, so it's best to order your manifest in the logical dependency
order.


StateListReachable
------------------
Summary: Looks for unreachable states in a <selector>

Priority: 5 / 10
Severity: Warning
Category: Correctness

In a selector, only the last child in the state list should omit a state
qualifier. If not, all subsequent items in the list will be ignored since the
given item will match all.


GridLayout
----------
Summary: Checks for potential GridLayout errors like declaring rows and
columns outside the declared grid dimensions

Priority: 4 / 10
Severity: Error
Category: Correctness

Declaring a layout_row or layout_column that falls outside the declared size
of a GridLayout's rowCount or columnCount is usually an unintentional error.


PxUsage
-------
Summary: Looks for use of the "px" dimension

Priority: 2 / 10
Severity: Warning
Category: Correctness

For performance reasons and to keep the code simpler, the Android system uses
pixels as the standard unit for expressing dimension or coordinate values.
That means that the dimensions of a view are always expressed in the code
using pixels, but always based on the current screen density. For instance, if
myView.getWidth() returns 10, the view is 10 pixels wide on the current
screen, but on a device with a higher density screen, the value returned might
be 15. If you use pixel values in your application code to work with bitmaps
that are not pre-scaled for the current screen density, you might need to
scale the pixel values that you use in your code to match the un-scaled bitmap
source.


More information: http://developer.android.com/guide/practices/screens_support.html#screen-independence

Security
========

ExportedService
---------------
Summary: Checks for exported services that do not require permissions

Priority: 5 / 10
Severity: Warning
Category: Security

Exported services (services which either set exported=true or contain an
intent-filter and do not specify exported=false) should define a permission
that an entity must have in order to launch the service or bind to it. Without
this, any application can use this service.


Performance
===========

UseCompoundDrawables
--------------------
Summary: Checks whether the current node can be replaced by a TextView using
compound drawables.

Priority: 6 / 10
Severity: Warning
Category: Performance

A LinearLayout which contains an ImageView and a TextView can be more
efficiently handled as a compound drawable


MergeRootFrame
--------------
Summary: Checks whether a root <FrameLayout> can be replaced with a <merge>
tag

Priority: 4 / 10
Severity: Warning
Category: Performance

If a <FrameLayout> is the root of a layout and does not provide background or
padding etc, it can be replaced with a <merge> tag which is slightly more
efficient.


InefficientWeight
-----------------
Summary: Looks for inefficient weight declarations in LinearLayouts

Priority: 3 / 10
Severity: Warning
Category: Performance

When only a single widget in a LinearLayout defines a weight, it is more
efficient to assign a width/height of 0dp to it since it will absorb all the
remaining space anyway. With a declared width/height of 0dp it does not have
to measure its own size first.


UnusedResources
---------------
Summary: Looks for unused resources

Priority: 3 / 10
Severity: Warning
Category: Performance

Unused resources make applications larger and slow down builds.

LIMITATIONS:
* If you are running lint from the command line instead of Eclipse, then the
analysis of Java files is pattern based rather than using an accurate parse
tree, so the results may not be accurate. (This limitation will go away
soon.)
* The analysis does not consider dependencies between projects, so if you have
a library project which defines resources and a project including the library
project referencing the resources, then the resources will still be reported
as unused.


UselessLeaf
-----------
Summary: Checks whether a leaf layout can be removed.

Priority: 2 / 10
Severity: Warning
Category: Performance

A layout that has no children or no background can often be removed (since it
is invisible) for a flatter and more efficient layout hierarchy.


UselessParent
-------------
Summary: Checks whether a parent layout can be removed.

Priority: 2 / 10
Severity: Warning
Category: Performance

A layout with children that has no siblings, is not a scrollview or a root
layout, and does not have a background, can be removed and have its children
moved directly into the parent for a flatter and more efficient layout
hierarchy.


TooDeepLayout
-------------
Summary: Checks whether a layout hierarchy is too deep

Priority: 1 / 10
Severity: Warning
Category: Performance

Layouts with too much nesting is bad for performance. Consider using a flatter
layout (such as RelativeLayout or GridLayout).The default maximum depth is 10
but can be configured with the environment variable ANDROID_LINT_MAX_DEPTH.


TooManyViews
------------
Summary: Checks whether a layout has too many views

Priority: 1 / 10
Severity: Warning
Category: Performance

Using too many views in a single layout in a layout is bad for performance.
Consider using compound drawables or other tricks for reducing the number of
views in this layout.

The maximum view count defaults to 80 but can be configured with the
environment variable ANDROID_LINT_MAX_VIEW_COUNT.


UnusedIds
---------
Summary: Looks for unused id's

Priority: 1 / 10
Severity: Warning
Category: Performance
NOTE: This issue is disabled by default!
You can enable it by adding --enable UnusedIds

This resource id definition appears not to be needed since it is not
referenced from anywhere. Having id definitions, even if unused, is not
necessarily a bad idea since they make working on layouts and menus easier, so
there is not a strong reason to delete these.


Usability
=========

TextFields
----------
Summary: Looks for text fields missing inputType or hint settings

Priority: 5 / 10
Severity: Warning
Category: Usability

Providing an inputType attribute on a text field improves usability because
depending on the data to be input, optimized keyboards can be shown to the
user (such as just digits and parentheses for a phone number). Similarly,a
hint attribute displays a hint to the user for what is expected in the text
field.

If you really want to keep the text field generic, you can suppress this
warning by setting inputType="text".


Usability:Icons
===============

IconNoDpi
---------
Summary: Finds icons that appear in both a -nodpi folder and a dpi folder

Priority: 7 / 10
Severity: Warning
Category: Usability:Icons

Bitmaps that appear in drawable-nodpi folders will not be scaled by the
Android framework. If a drawable resource of the same name appears *both* in a
-nodpi folder as well as a dpi folder such as drawable-hdpi, then the behavior
is ambiguous and probably not intentional. Delete one or the other, or use
different names for the icons.


GifUsage
--------
Summary: Checks for images using the GIF file format which is discouraged

Priority: 5 / 10
Severity: Warning
Category: Usability:Icons

The .gif file format is discouraged. Consider using .png (preferred) or .jpg
(acceptable) instead.


More information: http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap

IconDipSize
-----------
Summary: Ensures that icons across densities provide roughly the same
density-independent size

Priority: 5 / 10
Severity: Warning
Category: Usability:Icons

Checks the all icons which are provided in multiple densities, all compute to
roughly the same density-independent pixel (dip) size. This catches errors
where images are either placed in the wrong folder, or icons are changed to
new sizes but some folders are forgotten.


IconDuplicatesConfig
--------------------
Summary: Finds icons that have identical bitmaps across various configuration
parameters

Priority: 5 / 10
Severity: Warning
Category: Usability:Icons

If an icon is provided under different configuration parameters such as
drawable-hdpi or -v11, they should typically be different. This detector
catches cases where the same icon is provided in different configuration
folder which is usually not intentional.


IconExpectedSize
----------------
Summary: Ensures that launcher icons, notification icons etc have the correct
size

Priority: 5 / 10
Severity: Warning
Category: Usability:Icons
NOTE: This issue is disabled by default!
You can enable it by adding --enable IconExpectedSize

There are predefined sizes (for each density) for launcher icons. You should
follow these conventions to make sure your icons fit in with the overall look
of the platform.


More information: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size

IconLocation
------------
Summary: Ensures that images are not defined in the density-independent
drawable folder

Priority: 5 / 10
Severity: Warning
Category: Usability:Icons

The res/drawable folder is intended for density-independent graphics such as
shapes defined in XML. For bitmaps, move it to drawable-mdpi and consider
providing higher and lower resolution versions in drawable-ldpi, drawable-hdpi
and drawable-xhdpi. If the icon *really* is density independent (for example a
solid color) you can place it in drawable-nodpi.


More information: 

IconDensities
-------------
Summary: Ensures that icons provide custom versions for all supported
densities

Priority: 4 / 10
Severity: Warning
Category: Usability:Icons

Icons will look best if a custom version is provided for each of the major
screen density classes (low, medium, high, extra high). This lint check
identifies icons which do not have complete coverage across the densities.

Low density is not really used much anymore, so this check ignores the ldpi
density. To force lint to include it, set the environment variable
ANDROID_LINT_INCLUDE_LDPI=true. For more information on current density usage,
see http://developer.android.com/resources/dashboard/screens.html


More information: http://developer.android.com/guide/practices/screens_support.html

IconDuplicates
--------------
Summary: Finds duplicated icons under different names

Priority: 3 / 10
Severity: Warning
Category: Usability:Icons

If an icon is repeated under different names, you can consolidate and just use
one of the icons and delete the others to make your application smaller.
However, duplicated icons usually are not intentional and can sometimes point
to icons that were accidentally overwritten or accidentally not updated.


IconMissingDensityFolder
------------------------
Summary: Ensures that all the density folders are present

Priority: 3 / 10
Severity: Warning
Category: Usability:Icons

Icons will look best if a custom version is provided for each of the major
screen density classes (low, medium, high, extra high). This lint check
identifies folders which are missing, such as drawable-hdpi.
Low density is not really used much anymore, so this check ignores the ldpi
density. To force lint to include it, set the environment variable
ANDROID_LINT_INCLUDE_LDPI=true. For more information on current density usage,
see http://developer.android.com/resources/dashboard/screens.html


More information: http://developer.android.com/guide/practices/screens_support.html

Accessibility
=============

ContentDescription
------------------
Summary: Ensures that image widgets provide a contentDescription

Priority: 3 / 10
Severity: Warning
Category: Accessibility

Non-textual widgets like ImageViews and ImageButtons should use the
contentDescription attribute to specify a textual description of the widget
such that screen readers and other accessibility tools can adequately describe
the user interface.


Internationalization
====================

HardcodedText
-------------
Summary: Looks for hardcoded text attributes which should be converted to
resource lookup

Priority: 5 / 10
Severity: Warning
Category: Internationalization

Hardcoding text attributes directly in layout files is bad for several
reasons:

* When creating configuration variations (for example for landscape or
portrait)you have to repeat the actual text (and keep it up to date when
making changes)

* The application cannot be translated to other languages by just adding new
translations for existing string resources.

Wednesday 7 December 2011

Android Alert Dialog with ListView and Example of Simple AlertDialog

Here with Below Code for Use in  Eclipse with Android SDK ,you can create Simple Demo for Custom Alert Dialog With ListView in it .

First Things in for Use of java Code files is Below:

In Activity 's OnCreate Method Add Following Code .


mButton = (Button) findViewById(R.id.btnalert);
mButton_Sample=(Button)findViewById(R.id.simpleid);
mListview = new ListView(this);
values = new String[] { "ListItem1", "ListItem2", "ListItem3",
"ListItem4", "ListItem5", "ListItem6", "ListItem7",
"ListItem8", "ListItem9", "ListItem10" };
   //Adapter Use in ListView
adpter = new ArrayAdapter<String>(this,R.layout.simplelist_item_text, values);

mListview.setOnItemClickListener(this);
mListview.setAdapter(adpter);
prepareAlertDialog();

mButton_Sample.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
SimpleAlertDialog();
}
});

mButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mAlertDialog.show();
}
});


And Now After OnCreate Method brace Complete Add Following Method For Create Alert Dialog

This Method Create AlertDialog With ListView in it.

public void prepareAlertDialog() {
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
AlertDialog.Builder mBuider = new AlertDialog.Builder(
CustomAlertDialogActivity.this);
mBuider.setTitle("ListItems");
mBuider.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

// Do what you like on Ok Button
}
});
mBuider.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
mBuider.setView(mListview);
mAlertDialog = mBuider.create();

lp.copyFrom(mAlertDialog.getWindow().getAttributes());

}



//This Method For Create Simple AlertDialog In android

public void SimpleAlertDialog(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
      .setCancelable(false)
      .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
          CustomAlertDialogActivity.this.finish();
          }
      })
      .setNegativeButton("No", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
          }
      });
AlertDialog alert = builder.create();
alert.show();
}




And Finally Don't Forget To Activity to implements OnItemClickListener for Override this method used for Listview item.

@Override
public void onItemClick(AdapterView<?> adapter, View view, int position,
long log) {
// Do what you want on List Item Click
TextView mTextView;
mTextView = (TextView) view;
String txtstr;
txtstr = mTextView.getText().toString();
Toast.makeText(CustomAlertDialogActivity.this, "Your Select Item  is "+  txtstr, Toast.LENGTH_SHORT).show();
mAlertDialog.cancel();
}

in Your Class File Add Following Class member on Top


        ListView mListview;
Button mButton,mButton_Sample;
AlertDialog mAlertDialog;
String[] values;
ArrayAdapter<String> adpter;




Here are Some Used Layout Files in Demo.
main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
  
    <Button
        android:text="OpenAlert"
        android:id="@+id/btnalert"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
  
    <Button
        android:id="@+id/simpleid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="SimpleDialog"
        />

</LinearLayout>


<---------------------------------------                    ----------------------------------------------->
simplelist_item_text.xml

You can use this xml for text context in ListView to change Color,textsize,font etc

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:textColor="#0000FF"
/>



Saturday 26 November 2011

About Use of AndroidManifest.file in Android Project

Hello,Here are some Require Information From android developer to how we can manage androidmanifest.xml  in your android project.


Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:



  1. It names the Java package for the application. The package name serves as a unique identifier for the application.
  2. It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.
  3. It determines which processes will host application components.
  4. It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
  5. It also declares the permissions that others are required to have in order to interact with the application's components.
  6. It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published.
  7. It declares the minimum level of the Android API that the application requires.
  8. It lists the libraries that the application must be linked against.


Structure of the Manifest File:

The diagram below shows the general structure of the manifest file and every element that it can contain. Each element, along with all of its attributes, is documented in full in a separate file. To view detailed information about any element, click on the element name in the diagram, in the alphabetical list of elements that follows the diagram, or on any other mention of the element name.
<?xml version="1.0" encoding="utf-8"?>
<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />  
    <uses-feature />  
    <supports-screens />  
    <compatible-screens />  
    <supports-gl-texture />  

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
        </provider>

        <uses-library />

    </application>
</manifest>

Here is Example of Sample use of all types of Each and Every Tag of Manifest.
For:<uses-permission />



syntax:
<uses-permission android:name="string" />
contained in:
<manifest>
description:
Requests a permission that the application must be granted in order for it to operate correctly. Permissions are granted by the user when the application is installed, not while it's running.
For more information on permissions, see the Permissions section in the introduction and the separate Security and Permissions document. A list of permissions defined by the base platform can be found at android.Manifest.permission.
attributes:
android:name
The name of the permission. It can be a permission defined by the application with the<permission> element, a permission defined by another application, or one of the standard system permissions, such as "android.permission.CAMERA" or "android.permission.READ_CONTACTS". As these examples show, a permission name typically includes the package name as a prefix.
introduced in:
API Level 1
see also:




syntax:
<permission android:description="string resource"
            android:icon="drawable resource"
            android:label="string resource"
            android:name="string"
            android:permissionGroup="string"
            android:protectionLevel=["normal" | "dangerous" | 
                                     "signature" | "signatureOrSystem"] />
contained in:
<manifest>
description:
Declares a security permission that can be used to limit access to specific components or features of this or other applications. See the Permissionssection in the introduction, and the Security and Permissions document for more information on how permissions work.
attributes:
android:description
A user-readable description of the permission, longer and more informative than the label. It may be displayed to explain the permission to the user — for example, when the user is asked whether to grant the permission to another application.
This attribute must be set as a reference to a string resource; unlike the label attribute, it cannot be a raw string.
android:icon
A reference to a drawable resource for an icon that represents the permission.
android:label
A name for the permission, one that can be displayed to users.
As a convenience, the label can be directly set as a raw string while you're developing the application. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name of the permission. This is the name that will be used in code to refer to the permission — for example, in a <uses-permission> element and the permission attributes of application components.
The name must be unique, so it should use Java-style scoping — for example, "com.example.project.PERMITTED_ACTION".
android:permissionGroup
Assigns this permission to a group. The value of this attribute is the name of the group, which must be declared with the <permission-group>element in this or another application. If this attribute is not set, the permission does not belong to a group.
android:protectionLevel
Characterizes the potential risk implied in the permission and indicates the procedure the system should follow when determining whether or not to grant the permission to an application requesting it. The value can be set to one of the following strings:
ValueMeaning
"normal"The default value. A lower-risk permission that gives requesting applications access to isolated application-level features, with minimal risk to other applications, the system, or the user. The system automatically grants this type of permission to a requesting application at installation, without asking for the user's explicit approval (though the user always has the option to review these permissions before installing).
"dangerous"A higher-risk permission that would give a requesting application access to private user data or control over the device that can negatively impact the user. Because this type of permission introduces potential risk, the system may not automatically grant it to the requesting application. For example, any dangerous permissions requested by an application may be displayed to the user and require confirmation before proceeding, or some other approach may be taken to avoid the user automatically allowing the use of such facilities.
"signature"A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.
"signatureOrSystem"A permission that the system grants only to applications that are in the Android system image or that are signed with the same certificates as those in the system image. Please avoid using this option, as the signatureprotection level should be sufficient for most needs and works regardless of exactly where applications are installed. The "signatureOrSystem" permission is used for certain special situations where multiple vendors have applications built into a system image and need to share specific features explicitly because they are being built together.
introduced in:
API Level 1
see also:
<uses-permission>
<permission-tree>
<permission-group>

<permission-tree>

syntax:
<permission-tree android:icon="drawable resource"
                 android:label="string resource" ]
                 android:name="string" />
contained in:
<manifest>
description:
Declares the base name for a tree of permissions. The application takes ownership of all names within the tree. It can dynamically add new permissions to the tree by calling PackageManager.addPermission(). Names within the tree are separated by periods ('.'). For example, if the base name iscom.example.project.taxes, permissions like the following might be added:
com.example.project.taxes.CALCULATE
com.example.project.taxes.deductions.MAKE_SOME_UP
com.example.project.taxes.deductions.EXAGGERATE
Note that this element does not declare a permission itself, only a namespace in which further permissions can be placed. See the <permission> element for information on declaring permissions.
attributes:
android:icon
An icon representing all the permissions in the tree. This attribute must be set as a reference to a drawable resource containing the image definition.
android:label
A user-readable name for the group. As a convenience, the label can be directly set as a raw string for quick and dirty programming. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name that's at the base of the permission tree. It serves as a prefix to all permission names in the tree. Java-style scoping should be used to ensure that the name is unique. The name must have more than two period-separated segments in its path — for example, com.example.base is OK, butcom.example is not.
introduced in:
API Level 1
see also:
<permission>
<permission-group>
<uses-permission>

<permission-group>

syntax:
<permission-group android:description="string resource"
                  android:icon="drawable resource"
                  android:label="string resource"
                  android:name="string" />
contained in:
<manifest>
description:
Declares a name for a logical grouping of related permissions. Individual permission join the group through the permissionGroup attribute of the<permission> element. Members of a group are presented together in the user interface.
Note that this element does not declare a permission itself, only a category in which permissions can be placed. See the <permission> element for element for information on declaring permissions and assigning them to groups.
attributes:
android:description
User-readable text that describes the group. The text should be longer and more explanatory than the label. This attribute must be set as a reference to a string resource. Unlike the label attribute, it cannot be a raw string.
android:icon
An icon representing the permission. This attribute must be set as a reference to a drawable resource containing the image definition.
android:label
A user-readable name for the group. As a convenience, the label can be directly set as a raw string while you're developing the application. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.
android:name
The name of the group. This is the name that can be assigned to a <permission> element's <permissionGroup> attribute.
introduced in:
API Level 1
see also:
<permission>
<permission-tree>
<uses-permission>

<application>

syntax:
<application android:allowTaskReparenting=["true" | "false"]
             android:backupAgent="string"
             android:debuggable=["true" | "false"]
             android:description="string resource"
             android:enabled=["true" | "false"]
             android:hasCode=["true" | "false"]
             android:hardwareAccelerated=["true" | "false"]
             android:icon="drawable resource"
             android:killAfterRestore=["true" | "false"]
             android:label="string resource"
             android:logo="drawable resource"
             android:manageSpaceActivity="string"
             android:name="string"
             android:permission="string"
             android:persistent=["true" | "false"]
             android:process="string"
             android:restoreAnyVersion=["true" | "false"]
             android:taskAffinity="string"
             android:theme="resource or theme"
             android:uiOptions=["none" | "splitActionBarWhenNarrow"] >
    . . .</application>
contained in:
<manifest>
can contain:
<activity>
<activity-alias>
<service>
<receiver>
<provider>
<uses-library>
description:
The declaration of the application. This element contains subelements that declare each of the application's components and has attributes that can affect all the components. Many of these attributes (such as iconlabelpermissionprocesstaskAffinity, and allowTaskReparenting) set default values for corresponding attributes of the component elements. Others (such as debuggableenableddescription, and allowClearUserData) set values for the application as a whole and cannot be overridden by the components.
attributes
android:allowTaskReparenting
Whether or not activities that the application defines can move from the task that started them to the task they have an affinity for when that task is next brought to the front — "true" if they can move, and "false" if they must remain with the task where they started. The default value is "false".
The <activity> element has its own allowTaskReparenting attribute that can override the value set here. See that attribute for more information.
android:backupAgent
The name of the class that implement's the application's backup agent, a subclass of BackupAgent. The attribute value should be a fully qualified class name (such as, "com.example.project.MyBackupAgent"). However, as a shorthand, if the first character of the name is a period (for example, ".MyBackupAgent"), it is appended to the package name specified in the <manifest> element.
There is no default. The name must be specified.
android:debuggable
Whether or not the application can be debugged, even when running on a device in user mode — "true" if it can be, and "false" if not. The default value is "false".
android:description
User-readable text about the application, longer and more descriptive than the application label. The value must be set as a reference to a string resource. Unlike the label, it cannot be a raw string. There is no default value.
android:enabled
Whether or not the Android system can instantiate components of the application — "true" if it can, and "false" if not. If the value is "true", each component's enabled attribute determines whether that component is enabled or not. If the value is "false", it overrides the component-specific values; all components are disabled.
The default value is "true".
android:hasCode
Whether or not the application contains any code — "true" if it does, and "false" if not. When the value is "false", the system does not try to load any application code when launching components. The default value is "true".
An application would not have any code of its own only if it's using nothing but built-in component classes, such as an activity that uses theAliasActivity class, a rare occurrence.
android:hardwareAccelerated
Whether or not hardware-accelerated rendering should be enabled for all Activities and Views in this application — "true" if it should be enabled, and "false" if not. The default value is "false".
Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries.
Note that not all of the OpenGL 2D operations are accelerated. If you enable the hardware-accelerated renderer, test your application to ensure that it can make use of the renderer without errors.
android:icon
An icon for the application as whole, and the default icon for each of the application's components. See the individual icon attributes for <activity>,<activity-alias><service><receiver>, and <provider> elements.
This attribute must be set as a reference to a drawable resource containing the image (for example "@drawable/icon"). There is no default icon.
android:killAfterRestore
Whether the application in question should be terminated after its settings have been restored during a full-system restore operation. Single-package restore operations will never cause the application to be shut down. Full-system restore operations typically only occur once, when the phone is first set up. Third-party applications will not normally need to use this attribute.
The default is true, which means that after the application has finished processing its data during a full-system restore, it will be terminated.
android:label
A user-readable label for the application as a whole, and a default label for each of the application's components. See the individual label attributes for<activity><activity-alias><service><receiver>, and <provider> elements.
The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface. However, as a convenience while you're developing the application, it can also be set as a raw string.
android:logo
A logo for the application as whole, and the default logo for activities.
This attribute must be set as a reference to a drawable resource containing the image (for example "@drawable/logo"). There is no default logo.
android:manageSpaceActivity
The fully qualified name of an Activity subclass that the system can launch to let users manage the memory occupied by the application on the device. The activity should also be declared with an <activity> element.
android:name
The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components.
The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class.
android:permission
The name of a permission that clients must have in order to interact with the application. This attribute is a convenient way to set a permission that applies to all of the application's components. It can be overwritten by setting the permission attributes of individual components.
For more information on permissions, see the Permissions section in the introduction and another document, Security and Permissions.
android:persistent
Whether or not the application should remain running at all times — "true" if it should, and "false" if not. The default value is "false". Applications should not normally set this flag; persistence mode is intended only for certain system applications.
android:process
The name of a process where all components of the application should run. Each component can override this default by setting its own processattribute.
By default, Android creates a process for an application when the first of its components needs to run. All components then run in that process. The name of the default process matches the package name set by the <manifest> element.
By setting this attribute to a process name that's shared with another application, you can arrange for components of both applications to run in the same process — but only if the two applications also share a user ID and be signed with the same certificate.
If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed. If the process name begins with a lowercase character, a global process of that name is created. A global process can be shared with other applications, reducing resource usage.
android:restoreAnyVersion
Indicate that the application is prepared to attempt a restore of any backed-up data set, even if the backup was stored by a newer version of the application than is currently installed on the device. Setting this attribute to true will permit the Backup Manager to attempt restore even when a version mismatch suggests that the data are incompatible. Use with caution!
The default value of this attribute is false.
android:taskAffinity
An affinity name that applies to all activities within the application, except for those that set a different affinity with their own taskAffinity attributes. See that attribute for more information.
By default, all activities within an application share the same affinity. The name of that affinity is the same as the package name set by the<manifest> element.
android:theme
A reference to a style resource defining a default theme for all activities in the application. Individual activities can override the default by setting their owntheme attributes. For more information, see the Styles and Themes developer guide.
android:uiOptions
Extra options for an activity's UI.
Must be one of the following values.
ValueDescription
"none"No extra UI options. This is the default.
"splitActionBarWhenNarrow"Add a bar at the bottom of the screen to display action items in the ActionBar, when constrained for horizontal space (such as when in portrait mode on a handset). Instead of a small number of action items appearing in the action bar at the top of the screen, the action bar is split into the top navigation section and the bottom bar for action items. This ensures a reasonable amount of space is made available not only for the action items, but also for navigation and title elements at the top. Menu items are not split across the two bars; they always appear together.
For more information about the action bar, see the Action Bar developer guide.
This attribute was added in API level 14.
introduced in:
API Level 1
see also:
<activity>
<service>
<receiver>
<provider>

File Conventions

Some conventions and rules apply generally to all elements and attributes in the manifest:
Elements
Only the <manifest> and <application> elements are required, they each must be present and can occur only once. Most of the others can occur many times or not at all — although at least some of them must be present for the manifest to accomplish anything meaningful.
If an element contains anything at all, it contains other elements. All values are set through attributes, not as character data within an element.
Elements at the same level are generally not ordered. For example, <activity><provider>, and <service> elements can be intermixed in any sequence. (An <activity-alias> element is the exception to this rule: It must follow the <activity> it is an alias for.)
Attributes
In a formal sense, all attributes are optional. However, there are some that must be specified for an element to accomplish its purpose. Use the documentation as a guide. For truly optional attributes, it mentions a default value or states what happens in the absence of a specification.
Except for some attributes of the root <manifest> element, all attribute names begin with an android: prefix — for example,android:alwaysRetainTaskState. Because the prefix is universal, the documentation generally omits it when referring to attributes by name.
Declaring class names
Many elements correspond to Java objects, including elements for the application itself (the <application> element) and its principal components — activities (<activity>), services (<service>), broadcast receivers (<receiver>), and content providers (<provider>).
If you define a subclass, as you almost always would for the component classes (ActivityServiceBroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, an Service subclass might be declared as follows:
<manifest . . . >
    <application . . . >
        <service android:name="com.example.project.SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the string is appended to the application's package name (as specified by the<manifest> element's package attribute). The following assignment is the same as the one above:
<manifest package="com.example.project" . . . >
    <application . . . >
        <service android:name=".SecretService" . . . >
            . . .
        </service>
        . . .
    </application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
Multiple values
If more than one value can be specified, the element is almost always repeated, rather than listing multiple values within a single element. For example, an intent filter can list several actions:
<intent-filter . . . >
    <action android:name="android.intent.action.EDIT" />
    <action android:name="android.intent.action.INSERT" />
    <action android:name="android.intent.action.DELETE" />
    . . .</intent-filter>
Resource values
Some attributes have values that can be displayed to users — for example, a label and an icon for an activity. The values of these attributes should be localized and therefore set from a resource or theme. Resource values are expressed in the following format,
@[package:]type:name
where the package name can be omitted if the resource is in the same package as the application, type is a type of resource — such as "string" or "drawable" — and name is the name that identifies the specific resource. For example:
<activity android:icon="@drawable/smallPic" . . . >
Values from a theme are expressed in a similar manner, but with an initial '?' rather than '@':
?[package:]type:name
String values
Where an attribute value is a string, double backslashes ('\\') must be used to escape characters — for example, '\\n' for a newline or '\\uxxxx' for a Unicode character.