Wednesday, 8 August 2012

Setting the development environment

is an open source software toolkit created by Google and Open Handset Alliance. Initially developed for mobile phones, it has become a major application platform for a wide range of mobile devices.
The scope of this post is to summarize the steps needed to set the development environment and to start learning and developing Android applications.

Other topics that are part of this Android tutorial are accessible through Android Tutorial – Overview and contents.

Because it is a very efficient and attractive platform:
  • open source platform based on Linux;
  • portable across a wide range of mobile platforms;
  • optimized for low-power and low-memory devices;
  • supports Java applications based on the Dalvik virtual machine;
  • has multimedia support for 2D vector graphics, OpenGL, MP3, AVC and AAC;
  • increased application security;
  • component-based architecture for applications;
  • data storage solution based on SQLite;
Android has become one of the major mobile platforms along Windows Mobile, Symbian, iPhone and J2ME (Java Mobile Edition)
In order to learn and develop Android applications you need to (for Windows) :
  1. download and install the Java Development Kit (JDK); the latest is 7 but any version starting with JDK 6.0 is recommended; you can download the JDK from java.oracle.com; DO NOT install the JRE (Java Runtime Environment) because Eclipse and the Android SDK need the tools from the JDK (Java Development Kit); even if you have a 64bit system it is recommended to install the 32bit version because there are still some compatibility problems regarding the JDK, the Eclipse IDE and the Android SDK;
  2. install the Eclipse IDE; using an IDE is not required but it is recommended as it is going to save you a lot of time and it will let you concentrate on the solution rather than on how to compile, build and execute it; Eclipse is available at http://www.eclipse.org/ and you should download the Eclipse IDE for Java Developers or the Eclipse Classic version; same as the JDK install the 32bit version;
  3. download and install the Android SDK Starter Package; the are two distributions for the Starter Package, both available at developer.android.com/sdk/index.html; if you have Windows and you chose the installer, which is the recommended version, on Windows 7 you can get an error (bug) because the installer does not detect the Java JDK; the solution (in some cases) is to hit Back and after that Next to return to the JDK detection step; install the Android SDK to a permanent directory such as C:\Android;
  4. using the Android SDK Manager (installed at the previous step) download the Android SDK Components which include SDK Tools, documentation, platforms, libraries, USB Driver for Windows and samples; at the SDK Manager start it will check available downloads and updates but you can manage what components to download from the Available packages panel;
    Using Android SDK Manager to download the Android SDK Components Using Android SDK Manager to download the Android SDK Components
    Using Android SDK Manager to download the Android SDK Components Using Android SDK Manager to download the Android SDK Components
  5. install the ADT (Android Development Toolkit) Plugin for Eclipse:
    • in Eclipse menu select Help > Install New Software…;
    • click Add button, in the top-right corner;
      Install the ADT (Android Development Toolkit) Plugin for EclipseInstall the ADT (Android Development Toolkit) Plugin for Eclipse
    • in the Add Repository form, enter “Android ADT Plugin” (or whatever name you like) for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
    • click OK (If you have trouble acquiring the plugin, try using “http” in the Location URL, instead of “https“)
    • in the Available Software dialog, select the checkbox next to Developer Tools and click Next;
      Install the ADT (Android Development Toolkit) Plugin for EclipseInstall the ADT (Android Development Toolkit) Plugin for Eclipse
    • in the next window (install details and items review) click Next;
    • read and accept the license agreements (check the radio button) and click Finish;
  6. restart Eclipse;
  7. configure the Eclipse ADT plugin:
    • in Eclipse menu select Window > Preferences…to open the Preferencespanel;
      Configure the Eclipse ADT plugin Configure the Eclipse ADT plugin
    • in the Preferences window select Android category from the left panel;
    • in the main panel, click Browse… and locate the Android SDK directory (in this tutorial, the Android SDK was installed at step 3 in C:\Android);
    • click Apply, then OK.
  8. test the Android SDK and the Android Platform by running the emulator; to do this you must create an Android Virtual Device (AVD)using the Android SDK and AVD Manager:
    • open the Android SDK and AVD Manager from Start > Programs > Android SDK Tools or from Eclipse using the Window > Android SDK and AVD Manager menu option;
    • from the left panel, select the Virtual devices category;
    • in the main panel click the New… button;
      Create an Android Virtual Device (AVD) Create an Android Virtual Device (AVD)
    • in the Create new Android Virtual Device window set the name of the virtual emulator (A), the Android Platform (B), the size of the memory card (C), the emulator skin (D) and other hardware settings (E);
    • select the newly created virtual device and start the emulator using the Start… button;
Android Virtual Device Android Virtual Device

Monday, 6 August 2012

How to debug the Android mobile application with LogCat

When developing and testing an Android mobile application you can get a message like this:

The dialog window announces that the application has crashed, mainly because a runtime exceptions or error. Reasons for this situations are multiple and depends entirely on what you have done in the Android project. So, we now that something is wrong, but we have a a question:
How to find out what is the problem that forced the Android application to stop unexpectedly

Java programmers, that use Eclipse, know that if the application generates a runtime exception, they will get the exception details in the console window.

When developing Android applications in Eclipse the runtime exceptions messages are NOT displayed in the console window. Instead, the Android SDK comes with a tool, called LogCat, that logs all the platform messages.
How to open LogCat window

In Eclipse you can view the LogCat window by selecting Window -> Show View -> Other… and choosing LogCat from the Android category:
Open the Android LogCat View in EclipseOpen the Android LogCat View in Eclipse
The LogCat view displays logs generated by the Android emulator and by the mobile application:
LogCat View window in EclipseLogCat View window in Eclipse
Also, using the LogCat top toolbar you can filter logs based on their Tag, pid or Log Level (Error, Warning, Info, Debug, Verbose) or you can define your own custom filter.
LogCat Custom Filter EditorLogCat Custom Filter Editor

How to display messages in the LogCat window from code

A simple debugging technique is to display your own messages in the log window. For Java applications, this is done by printing messages in the console window using System.out.println(String message) method.
For Android projects, there is a better solution. The Log class has some static methods used to print messages in the system log which is displayed by LogCat view. Each method prints a message with a predefined log level:
        Log.e("MyTag", "Error message with my own tag");
        Log.w("dalvikvm", "VM Warning message");
        Log.d("MyTag", "Debug message");
        Log.i("MainActivity","Information message");
        Log.v("MyTag", "Verbose message");
        Log.wtf("WTF", "What a Terrible Failure");
The methods have multiple signatures. The previous example shows only the (String Tag, String Message) one. For tags is recommended to use your own tags or the class name. This will allow you to filter them easily.

Sunday, 5 August 2012

How to create and display a new form, window or activity


In this post we will see what are the basics for developing an Android mobile application that has multiple windows or activities. To do that, we need to know how to create and display a new form, window or activity (for the rest of the post we will use the Android vocabulary and call it just activity).


To achieve the proposed objective, to create and display a new Activity, we define the solution steps:

    define a widget on the main activity display used to open the new Activity;
    define the new Activity and its layout; also declare the activity in the Android application manifest file, the AndroidManifest.xml;
    define in the main activity the event and its handler that will display the new Activity;

We will start by creating the skeleton Android project using the Eclipse ADT plugin with the next settings:

    Project Name: AndroidSecondActivity
    Build target: Android 2.3.3
    Application Name: Create and display a new Activity
    Package name: eu.itcsolutions.android.tutorial
    Create Activity: MainActivity
    Min SDK Version: 10

Step 1. The main Activity user interface will be designed in a declarative manner because we will use Java code for more complex things. In order to open the new Activity we will provide a Button on the display. When the user clicks it, the new Activity will be displayed.

1.1. Edit the project /res/values/strings.xml file and add a new item. Use the text editor and not the Resources visual editor, as the first one is faster. Add the item after the existing ones, on line 5 (hello is for the TextView and app_name is for the main Activity title bar):

 1: <?xml version="1.0" encoding="utf-8"?>

 2: <resources>

 3:     <string name="hello">Hello World, MainActivity!</string>

 4:     <string name="app_name">Create and display a new Activity</string>

 5:     <string name="btnClick">Click me !</string>

 6: </resources>


1.2. Add a Button instance on the display by editing the project /res/layout/main.xml. You can delete the existing TextView that has the hello message. The Button instance properties that we initialize are:

    Text: the btnClick string in strings.xml file. If you use the declarative design then the element is accessed using “@string/btnClick”. For procedural design the string resource is accessed using getString(R.string.btnClick).
    Width: wrap_content which is equal to the size of the text;
    Height: wrap_content
    Id: buttonClick. If you use the declarative design then the id of the Button instance is defined using the android:id property. The property gets a value with the “@+id/id_name” syntax. The android:id property is the equivalent of the Button reference when writing Java code and it will be used to refer that particular Button instance (remember that when you use declarative design you don’t write any Java code, but later you may want to access the Button from the code). If you use the graphical layout editor to place the button on the screen, it will generate a default id (android:id=”@+id/button1?) for the Button instance. If you don’t use the graphical layout editor add it in the <Button> description.

Either you use the layout graphical layout editor or not, the main.xml file should look like this (I have deleted the existing TextView and centered the content using of the android:gravity attribute of the LinearLayout element:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    >
<Button
    android:text="@string/btnClick"
    android:id="@+id/buttonClick"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</Button>
</LinearLayout>

Step 2.To define a new Activity we must create a new class that extends Activity and also a new layout for it. To do that we have two possibilities. One is to get our hands dirty and write everything form zero and the second option is to use the Manifest visual editor (a WYSIWYG editor with tabs at the bottom which is opened by default when you select the manifest file) that generates part of the needed code (see How to create a new Activity class with the Manifest editor or without it). In this example I will use the first approach. To open the simple XML text editor, select the tab with the manifest file name on it (the last tab) from the WYSIWYG editor.

2.1. The class is created as a common Java class, using File –> New –> Class. Name it SecondActivity and set android.app.Activity as its superclass:
2.2. Because the ADT plugin is not so helpful when creating a new Activity class, in this manner, you must edit it from scratch:

package eu.itcsolutions.android.tutorial;

import android.app.Activity;
import android.os.Bundle;

public class SecondActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }
}

2.3. Let’s define a layout for the new Activity. For that, Eclipse is somehow helpful because there is a New Android XML File wizard. To open it, select the project and use File –> New –> Other and from the Android category select Android XML File.

Name the new layout file, second.xml and edit it by placing a TextView on it. The text of the TextView is set in the layout file (not recommended).

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
<TextView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:text="This is the second Activity"
/>
</LinearLayout>

2.4. Link the layout file second.xml with the SecondActivity by calling setContentView() in the class onCreate() method:

        this.setContentView(R.layout.second);

2.5. Important ! Declare the SecondActivity in the Android project manifest file, AndroidManifest.xml. To do that, you can use the Android Manifest Application tab or you can use the XML text editor (the AndroidManifest.xml tab). I will use the latter option and I will add the next line in the XML file, between <application> and </application> (after the main Activity declaration):

<activity
        android:name="SecondActivity"
        android:label="Second Activity">
</activity>



Step 3. The event that will display the second activity is generated when the user clicks the button. The event-handler architecture is the same as in any Java JSE application. The event is managed by the system and the application defines and register listeners for that event.

3.1. The event listener is the button from the main Activity. To register it as a listener we must reference the button instance from Java code. But the button has been defined in the XML layout file.

Important !
    To get the reference of a View item, defined in the layout XML file, you can use the View class findViewById(int ID) method. As argument, use the static constant from the R generated class. Also, the XML element must have an android:id attribute with a “@+id/id_name” like value.

After we get the Button reference with a call to findViewById(int ID) method, we register it as a listener using setOnCLickListener() method. This is done in the main Activity onCreate() method after the call to setContentView():

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

    //get the Button reference
    //Button is a subclass of View
    //buttonClick if from main.xml "@+id/buttonClick"
        View v = findViewById(R.id.buttonClick);
    //set event listener
        v.setOnClickListener(this);
    }

After adding the previous code, you will get a compiler error. We will solve it right away.

As you can see, the setOnCLickListener(OnCLickListener l) method requires a reference to an instance of a class that implements the OnClickListener interface, providing a handler for the event.

3.2. The define a handler for the OnClick event we will implement the android.view.View.OnClickListener interface. The interface has an abstract method, onClick(), that we must override. Modify the MainActivity class:

//implement the OnClickListener interface
public class MainActivity extends Activity
    implements OnClickListener {

        ...

        //overrides the OnClickListener interface method
    @Override
    public void onClick(View arg0) {

    }
}

3.3. The onClick(View arg0) method parameter represents the reference to the widget that launched the event when it was clicked. We compare it to our button reference (we have a single button, but it is best practice to check it).

3.4. As you remember from Android Tutorial (02) – Applications key concepts, activities and resources, the Intent component represents an asynchronous message used to activate activities. So if we want to display a new activity we must do use an Intent reference. The second activity is displayed using the startActivity() method of the Activity class.

@Override
public void onClick(View arg0) {
    if(arg0.getId() == R.id.buttonClick){
        //define a new Intent for the second Activity
        Intent intent = new Intent(this,SecondActivity.class);

        //start the second Activity
        this.startActivity(intent);
    }
}

Friday, 3 August 2012

How to put your app in Google Play

If you are creating an application that you want to distribute to the public the best way to do so is to upload your application to Google Play. Google has help specifically aimed at developers and if you have any questions not answered by this article it’s a great reference: Google Play for Developers Help. There is also a very useful document entitled: Publishing Checklist for Google Play that discusses what is required to publish to Google Play.

Note: Before publishing it is important to decided whether or not you want to charge money for your application. More information on this decision can be found in the You can't charge for previously published free apps knowledge base article.
Register for Google Play

The first step in publishing is to register for Google Play at the Google Play publisher site. The process is relatively straightforward and should only take you a few minutes. Note: There is a $25 USD charge to register.
Uploading your APK

Once you have registered, you can log in to your Google Play developer account and begin publishing your application via the "Upload Application" button. The first step in this process is to upload your application’s Android Package file (APK). This file is emailed to you whenever you successfully build your application, and can be downloaded at anytime from your projects section on Andromo.

Once you have uploaded your APK file, be sure to switch the APK files tab and activate the APK file that you have uploaded. This tells Google Play which APK file to use.
Required Assets

Along with your application’s APK file you will also need to upload some additional assets when publishing to Google Play. The Google Play help details required and optional assets in the uploading applications area.

There are two graphical assets that you are required to upload before you can publish:

    Two screenshots or your application at one of the following sizes: 320x480, 480x800, 480x854, or 1280x800
    A high-res 512x512 application icon.

Information on taking screenshots can be found in the How to take screenshots of your application knowledge base article.
Listing Details

The listing details are what your end users will see when they find your application in Google Play. The available listing details are described in detail in Google’s uploading applications help topic.
Editing your Listing

If you want to go back to edit your listing, or upload a new version of your application you can. When you make your changes simply save them and they should be live in the store in twenty minutes or so. Note: This can sometimes take quick a while so be patient.
Finishing Up

When you are done you can publish using the Publish button. Your application should appear in the store after a few minutes. After you have published your application into the store be sure to add your application to the Andromo showcase via the promote option. The promote option is available on your projects page or on the promote tab when editing your project.

Thursday, 2 August 2012

Installing the Eclipse Plugin For Android


Android offers a custom plugin for the Eclipse IDE, called Android Development Tools (ADT). This plugin is designed to give you a powerful, integrated environment in which to develop Android apps. It extends the capabilites of Eclipse to let you quickly set up new Android projects, build an app UI, debug your app, and export signed (or unsigned) app packages (APKs) for distribution.

If you will be developing in Eclipse with the ADT Plugin, first make sure that you have a suitable version of Eclipse installed on your computer as described by the system requirements.

If you need to install Eclipse, you can download it from http://www.eclipse.org/downloads/. We recommend the "Eclipse Classic" version. Otherwise, you should use a Java or RCP version of Eclipse.

Note: If you prefer to work in a different IDE, you do not need to install Eclipse or ADT. Instead, you can directly use the SDK tools to build and debug your application. So if you're not using Eclipse, continue to the next page by clicking the Next link on the right.
Download the ADT Plugin

    Start Eclipse, then select Help > Install New Software....
    Click Add, in the top-right corner.
    In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:

    https://dl-ssl.google.com/android/eclipse/

    Click OK

    Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
    In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
    In the next window, you'll see a list of the tools to be downloaded. Click Next.
    Read and accept the license agreements, then click Finish.

    Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
    When the installation completes, restart Eclipse.

Configure the ADT Plugin

After you've installed ADT and restarted Eclipse, you must specify the location of your Android SDK directory:

    Select Window > Preferences... to open the Preferences panel (on Mac OS X, select Eclipse > Preferences).
    Select Android from the left panel.

    You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed.
    For the SDK Location in the main panel, click Browse... and locate your downloaded Android SDK directory (such as android-sdk-windows).
    Click Apply, then OK.

If you haven't encountered any errors, you're done setting up ADT and can continue to the next step of the SDK installation.
Updating the ADT Plugin

From time to time, a new revision of the ADT Plugin becomes available, with new features and bug fixes. Generally, when a new revision of ADT is available, you should update to it as soon as convenient.

In some cases, a new revision of ADT will have a dependency on a specific revision of the Android SDK Tools. If such dependencies exist, you will need to update the SDK Tools package of the SDK after installing the new revision of ADT. To update the SDK Tools package, use the Android SDK Manager, as described in Exploring the SDK.

To learn about new features of each ADT revision and also any dependencies on the SDK Tools, see the listings in the Revisions section. To determine the version currently installed, open the Eclipse Installed Software window using Help > Software Updates and refer to the version listed for "Android Development Tools".

Follow the steps below to check whether an update is available and, if so, to install it.

    Select Help > Check for Updates.

    If there are no updates available, a dialog will say so and you're done.
    If there are updates available, select Android DDMS, Android Development Tools, and Android Hierarchy Viewer, then click Next.
    In the Update Details dialog, click Next.
    Read and accept the license agreement and then click Finish. This will download and install the latest version of Android DDMS and Android Development Tools.
    Restart Eclipse.

If you encounter problems during the update, remove the existing ADT plugin from Eclipse, then perform a fresh installation, using the instructions for Installing the ADT Plugin.
Troubleshooting

If you are having trouble downloading the ADT plugin after following the steps above, here are some suggestions:

    If Eclipse can not find the remote update site containing the ADT plugin, try changing the remote site URL to use http, rather than https. That is, set the Location for the remote site to:

    http://dl-ssl.google.com/android/eclipse/

Wednesday, 1 August 2012

Android 4.1 for Developers Jelly Bean



Welcome to Android 4.1, Jelly Bean!

Android 4.1 is the fastest and smoothest version of Android yet. We’ve made improvements throughout the platform and added great new features for users and developers. This document provides a glimpse of what's new for developers.

See the Android 4.1 APIs document for a detailed look at the new developer APIs,
Faster, Smoother, More Responsive

Android 4.1 is optimized to deliver Android's best performance and lowest touch latency, in an effortless, intuitive UI.

To ensure a consistent framerate, Android 4.1 extends vsync timing across all drawing and animation done by the Android framework. Everything runs in lockstep against a 16 millisecond vsync heartbeat — application rendering, touch events, screen composition, and display refresh — so frames don’t get ahead or behind.

Android 4.1 also adds triple buffering in the graphics pipeline, for more consistent rendering that makes everything feel smoother, from scrolling to paging and animations.

Android 4.1 reduces touch latency not only by synchronizing touch to vsync timing, but also by actually anticipating where your finger will be at the time of the screen refresh. This results in a more reactive and uniform touch response. In addition, after periods of inactivity, Android applies a CPU input boost at the next touch event, to make sure there’s no latency.

Tooling can help you get the absolute best performance out of your apps. Android 4.1 is designed to work with a new tool called systrace, which collects data directly from the Linux kernel to produce an overall picture of system activities. The data is represented as a group of vertically stacked time series graphs, to help isolate rendering interruptions and other issues. The tool is available now in the Android SDK (Tools R20 or higher)


Enhanced Accessibility

New APIs for accessibility services let you handle gestures and manage accessibility focus as the user moves through the on-screen elements and navigation buttons using accessibility gestures, accessories, and other input. The Talkback system and explore-by-touch are redesigned to use accessibility focus for easier use and offer a complete set of APIs for developers.

Accessibility services can link their own tutorials into the Accessibility settings, to help users configure and use their services.

Apps that use standard View components inherit support for the new accessibility features automatically, without any changes in their code. Apps that use custom Views can use new accessibility node APIs to indicate the parts of the View that are of interest to accessibility services.


Support for International Users

Bi-Directional Text and Other Language Support

Android 4.1 helps you to reach more users through support for bi-directional text in TextView and EditText elements. Apps can display text or handle text editing in left-to-right or right-to-left scripts. Apps can make use of new Arabic and Hebrew locales and associated fonts.

Other types of new language support include:

    Additional Indic languages: Kannada, Telugu, and Malayalam
    The new Emoji characters from Unicode version 6.0
    Better glyph support for Japanese users (renders Japanese-specific versions of glyphs when system language is set to Japanese)
    Arabic glyphs optimized for WebViews in addition to the Arabic glyphs for TextViews
    Vertical Text support in WebViews, including Ruby Text and additional Vertical Text glyphs
    Synthetic Bold is now available for all fonts that don't have dedicated bold glyphs

User-installable keymaps

The platform now supports user-installable keyboard maps, such as for additional international keyboards and special layout types. By default, Android 4.1 includes 27 international keymaps for keyboards, including Dvorak. When users connect a keyboard, they can go to the Settings app and select one or more keymaps that they want to use for that keyboard. When typing, users can switch between keymaps using a shortcut (ctrl-space).

You can create an app to publish additional keymaps to the system. The APK would include the keyboard layout resources in it, based on standard Android keymap format. The application can offer additional keyboard layouts to the user by declaring a suitable broadcast receiver for ACTION_QUERY_KEYBOARD_LAYOUTS in its manifest.

New Media Capabilities
Media codec access

Android 4.1 provides low-level access to platform hardware and software codecs. Apps can query the system to discover what low-level media codecs are available on the device and then and use them in the ways they need. For example, you can now create multiple instances of a media codec, queue input buffers, and receive output buffers in return. In addition, the media codec framework supports protected content. Apps can query for an available codec that is able to play protected content with a DRM solution available on the the device.
USB Audio

USB audio output support allows hardware vendors to build hardware such as audio docks that interface with Android devices. This functionality is also exposed with the Android Open Accessory Development Kit (ADK) to give all developers the chance to create their own hardware.
Audio record triggering

Android now lets you trigger audio recording based on the completion of an audio playback track. This is useful for situations such as playing back a tone to cue your users to begin speaking to record their voices. This feature helps you sync up recording so you don’t record audio that is currently being played back and prevents recordings from beginning too late.
Multichannel audio

Android 4.1 supports multichannel audio on devices that have hardware multichannel audio out through the HDMI port. Multichannel audio lets you deliver rich media experiences to users for applications such as games, music apps, and video players. For devices that do not have the supported hardware, Android automatically downmixes the audio to the number of channels that are supported by the device (usually stereo).

Android 4.1 also adds built-in support for encoding/decoding AAC 5.1 audio.
Audio preprocessing

Developers can apply preprocessing effects to audio being recorded, such as to apply noise suppression for improving speech recording quality, echo cancellation for acoustic echo, and auto gain control for audio with inconsistent volume levels. Apps that require high quality and clean audio recording will benefit from these preprocessors.
Audio chaining

MediaPlayer supports chaining audio streams together to play audio files without pauses. This is useful for apps that require seamless transitions between audio files such as music players to play albums with continuous tracks or games.
Media Router

The new APIs MediaRouter, MediaRouteActionProvider, and MediaRouteButton provide standard mechanisms and UI for choosing where to play media. Support is built-in for wired headsets and a2dp bluetooth headsets and speakers, and you can add your own routing options within your own app.

Tuesday, 31 July 2012

phonegap-powerapp / AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.powerapp"
    android:versionCode="2"
    android:versionName="1.1" >

    <uses-sdk android:minSdkVersion="7" />

    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"
        android:resizeable="true"
        android:anyDensity="true"
        />

    <uses-permission android:name="android.permission.CAMERA" />
    <!-- <uses-permission android:name="android.permission.VIBRATE" /> -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> -->
    <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
    <!-- <uses-permission android:name="android.permission.RECORD_VIDEO"/> -->
    <!-- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> -->
    <!-- <uses-permission android:name="android.permission.READ_CONTACTS" /> -->
    <!-- <uses-permission android:name="android.permission.WRITE_CONTACTS" /> -->
    <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- <uses-permission android:name="android.permission.GET_ACCOUNTS" /> -->
    <!-- <uses-permission android:name="android.permission.BROADCAST_STICKY" /> -->
    <uses-permission android:name="android.permission.FLASHLIGHT" />

    <application android:debuggable="true" android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity android:configChanges="orientation|keyboardHidden" android:name=".PowerAppActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
      
        <!-- ZXing activities -->
        <activity android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name">
            <intent-filter>
                <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
             <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
    </application>

</manifest>