Showing posts with label AndroidManifest. Show all posts
Showing posts with label AndroidManifest. Show all posts

How to Register an Activity that Responds to NFC tags for URI's that point to a URL

This will register an Activity that will respond only to NFC tags that correspond to a URI that points a website (URL).
ACTION_NDEF_DISCOVERED(added in API level 10) is an Intent to start an activity when a tag with NDEF payload is discovered.

1. Add a new activity to your AndroidManifest.xml file. You may add it below  a closing (</activity) tag.

<activity android:name=".BlogViewer">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http:"
   android:host="androidsbs.blogspot.com"/>
</intent-filter>
</activity>

2. Compile and run!

Resources:Professional Android 4 Application Development by Reto Meier, pg 694
http://developer.android.com/reference/android/nfc/NfcAdapter.html#ACTION_NDEF_DISCOVERED

How to Set the Install Location of your App

android:installLocation was added in API Level 8
Allows your app to be installed on external storage. If android:installLocation is not included, your app be installed internally only, and not movable.
1. In the AndroidManifest.xml file, add the below line between the <manifest> tags. This will set the application to automatically install on external storage, if available. 

<manifest
    ...
     android:installLocation="preferExternal"
</manifest>

2. Compile and run!

3. All optional settings:

preferExternal: you request that your application be installed on the external storage, but the system does not guarantee that your application will be installed on the external storage. If the external storage is full, the system will install it on the internal storage. The user can also move your application between the two locations.

auto: you indicate that your application may be installed on the external storage, but you don't have a preference of install location. The system will decide where to install your application based on several factors. The user can also move your application between the two locations.
internalOnly: the application must be installed on the internal device storage only. If this is set, the application will never be installed on the external storage. If the internal storage is full, then the system will not install the application. This is also the default behavior if you do not define android:installLocation.

4. When an application is installed on the external storage:

* The .apk file is saved to the external storage, but any application data (such as databases) is still saved on the internal device memory.
* The container in which the .apk file is saved is encrypted with a key that allows the application to operate only on the device that installed it. (A user cannot transfer the SD card to another device and use applications installed on the card.) Though, multiple SD cards can be used with the same device.
* At the user's request, the application can be moved to the internal storage.

Resources: http://developer.android.com/guide/topics/data/install-location.html
http://developer.android.com/guide/topics/manifest/manifest-element.html


How to Set the Application Version in your Android App

android:versionName — A string value that represents the release version of the application code, as it should be shown to users.
The value is a string so that you can describe the application version as a <major>.<minor>.<point> string, or as any other type of absolute or relative version identifier.
The system does not use this value for any internal purpose, other than to enable applications to display it to users. Publishing services may also extract the android:versionName value for display to users.

1. In the AndroidManifest.xml file, add the below line between the <manifest> tags.

<manifest
    ...
    android:versionName="1.1">
</manifest>

2. Compile and run!

Resources:
http://developer.android.com/tools/publishing/versioning.html

How to Set the Version of your Android App

android:versionCode — An integer value that represents the version of the application code, relative to other versions.

1. In the AndroidManifest.xml file, add the following line between the manifest tags

<manifest xmlns...
    android:versionCode="1"
</manifest>

2. Compile and run!

Solution: Failure: -INSTALL_FAILED_OLDER_SDK

Problem: Failure: -INSTALL_FAILED_OLDER_SDK

Solution:

The android:minSdkVersion is higher than the device you are trying to install it on. 

Determine the device android version and change the android:minSdkVersion to that version or lower. 

1. Open the AndroidManifest.xml file

2. Change the    android:minSdkVersion to lower.
Example:  Change from 11 to 10. 
     <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />
3. Compile and run!


android:minSdkVersion - Set the Minimum and Target SDK version for your Android App

How to Set the Minimum and Target SDK version for your Android App

android:minSdkVersion - the minimum version of Android that the user must be running for the application to run properly on his or her device. android:minSdkVersion is not required for an Android project. However, if a minSdkVersion is not indicated, a default value of 1 will be used.

1. Create a new Android project, if you don't already have one.

2. Open the AndroidManifest.xml file and add the following highlighted code below after the<manfest> tags and before the <application> tags. This will set the Minimum SDK Version to API Level 11 and the Target SDK Version to API Level 17.

</manifest>

 <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">

3. Compile and run!

Resources:
- Professional Android 4 Application Development by Reto Meier
- Android Application Development For Dummies by Donn Felker