Pages

Friday 30 December 2011

Android-Wheel: http://code.google.com/p/android-wheel/
It comes with a handy ScrollListener for listen to touch events on the wheel component. 

source code 

package com.vijay;


import com.vijay.wheel.ArrayWheelAdapter;
import com.vijay.wheel.OnWheelChangedListener;
import com.vijay.wheel.OnWheelScrollListener;
import com.vijay.wheel.WheelView;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity
    {
        // TODO: Externalize string-array
        String wheelMenu1[] = new String[]{"name 1", "name 2", "name 3", "name 4", "name 5", "name 6","name 7","name 8","name 9"};
        String wheelMenu2[] = new String[]{"age 1", "age 2", "age 3"};
        String wheelMenu3[] = new String[]{"10", "20","30","40","50","60"};

        // Wheel scrolled flag
        private boolean wheelScrolled = false;

        private TextView text;
        private EditText text1;
        private EditText text2;
        private EditText text3;

        @Override
        public void onCreate(Bundle savedInstanceState)
            {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                initWheel1(R.id.p1);
                initWheel2(R.id.p2);
                initWheel3(R.id.p3);

                text1 = (EditText) this.findViewById(R.id.r1);
                text2 = (EditText) this.findViewById(R.id.r2);
                text3 = (EditText) this.findViewById(R.id.r3);
                text = (TextView) this.findViewById(R.id.result);
            }

        // Wheel scrolled listener
        OnWheelScrollListener scrolledListener = new OnWheelScrollListener()
            {
                public void onScrollStarts(WheelView wheel)
                    {
                        wheelScrolled = true;
                    }

                public void onScrollEnds(WheelView wheel)
                    {
                        wheelScrolled = false;
                        updateStatus();
                    }
            };

        // Wheel changed listener
        private final OnWheelChangedListener changedListener = new OnWheelChangedListener()
            {
                public void onChanged(WheelView wheel, int oldValue, int newValue)
                    {
                        if (!wheelScrolled)
                            {
                                updateStatus();
                            }
                    }
            };

        /**
         * Updates entered PIN status
         */
        private void updateStatus()
            {
                text1.setText(wheelMenu1[getWheel(R.id.p1).getCurrentItem()]);
                text2.setText(wheelMenu2[getWheel(R.id.p2).getCurrentItem()]);
                text3.setText(wheelMenu3[getWheel(R.id.p3).getCurrentItem()]);

                text.setText(wheelMenu1[getWheel(R.id.p1).getCurrentItem()] + " - " + wheelMenu2[getWheel(R.id.p2).getCurrentItem()] + " - " + wheelMenu3[getWheel(R.id.p3).getCurrentItem()]);
            }

        /**
         * Initializes wheel
         * 
         * @param id
         *          the wheel widget Id
         */

        private void initWheel1(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);
                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu1));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        private void initWheel2(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);
                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu2));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        private void initWheel3(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);

                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu3));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        /**
         * Returns wheel by Id
         * 
         * @param id
         *          the wheel Id
         * @return the wheel with passed Id
         */
        private WheelView getWheel(int id)
            {
                return (WheelView) findViewById(id);
            }

        /**
         * Tests wheel value
         * 
         * @param id
         *          the wheel Id
         * @param value
         *          the value to test
         * @return true if wheel value is equal to passed value
         */
        private int getWheelValue(int id)
            {
                return getWheel(id).getCurrentItem();
            }
    }

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="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/layout_bg">


    <LinearLayout
        android:layout_marginTop="24dp"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <com.vijay.wheel.WheelView
            android:id="@+id/p1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
        <com.vijay.wheel.WheelView
            android:id="@+id/p2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
        <com.vijay.wheel.WheelView
            android:id="@+id/p3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp">
        <EditText
            android:id="@+id/r1"
            android:layout_width="100dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
        <EditText
            android:id="@+id/r2"
            android:layout_width="80dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
        <EditText
            android:id="@+id/r3"
            android:layout_width="80dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
    </LinearLayout>

    <TextView
        android:id="@+id/result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:layout_gravity="center_horizontal"
        android:textSize="18sp"
        android:textColor="#FFF"
        android:text="Your choice">
    </TextView>
</LinearLayout>

Android Tips

what is the folder structure of android?
1. src - It contain the java code
2. Resource - It contain the all resource with different floder
drawable - Icon
raw - Sounds
menu - Menu
values - Project Properties
layout - User interface Screens
3. gen - It contains the R.java file. You could not edit R.java manually. This have been generated automatically by understanding resource files etc.
4. AndroidManifest -It contains the Project properties
5. Android lib.


 what are the api available in the Android?
Activity Manager,

WindowManager, 
Location Manager,
View System, 
Notification Manager,
Telephonic Manager, 
Package Manager,
Resource Manager,

Friday 16 December 2011

Android 4.x Ice Cream Sandwich features


4.0.1

The Galaxy Nexus introduced Android 4.0.1 Ice Cream Sandwich.
Android 4.0 – codenamed Ice Cream Sandwich – was previewed at the May 2011 Google I/O event, and officially launched at the Galaxy Nexus and Ice Cream Sandwich release event on 19 October 2011.The SDK for Android 4.0.1 was publicly released on 19 October 2011.Google's Gabe Cohen stated that ICS was "theoretically compatible" with any Android 2.3.x device in production at that time.Thesource code for ICS became available on 14 November 2011, three days before the Galaxy Nexus was released. New features include:[58][59][60]
  • Enhanced speed and performance
  • Virtual buttons in the UI, in place of capacitive or physical buttons
  • Separation of widgets in a new tab, listed in a similar manner to apps
  • Easier-to-create folders, with a drag-and-drop style
  • A customizable launcher
  • Improved visual voicemail with the ability to speed up or slow down voicemail messages
  • Pinch-to-zoom functionality in the calendar
  • Offline search, a two-line preview, and new action bar at the bottom of the Gmail app
  • Ability to swipe left or right to switch between Gmail conversations
  • Integrated screenshot capture (accomplished by holding down the Power and Volume-Down buttons)
  • Improved error correction on the keyboard
  • Ability to access apps directly from lock screen (similar to HTC Sense 3.x)
  • Improved copy and paste functionality
  • Better voice integration and continuous, real-time speech to text dictation
  • Face Unlock, a feature that allows users to unlock handsets using facial recognition software
  • New tabbed web browser, allowing up to 16 tabs
  • Automatic syncing of browser with users' Chrome bookmarks
  • Modern Roboto font
  • Data Usage section in settings that lets users set warnings when they approach a certain usage limit, and disable data use when the limit is exceeded
  • Ability to shut down apps that are using data in the background
  • Improved camera app with zero shutter lag, time lapse settings, panorama mode, and the ability to zoom while recording
  • Built-in photo editor
  • New gallery layout, organized by location and person
  • Refreshed "People" app with social network integration, status updates and hi-res images
  • Android Beam, a near-field communication feature allowing the rapid short-range exchange of web bookmarks, contact info, directions, YouTube videos and other data
  • Hardware acceleration of the UI
  • Resizeable widgets – already part of Android 3.1 for tablets, but new for cellphones
  • Wi-Fi Direct[
  • 1080p video recording for stock Android devices


4.0.2

The Android 4.0.2 update was released on 28 November 2011, and fixed minor bugs on the Verizon Galaxy Nexus, the launch of which was later delayed.

Android 3.x Honeycomb features


3.0

The Motorola Xoom tablet introduced Android 3.0.1 Honeycomb.
On 22 February 2011, the Android 3.0 (Honeycomb) SDK – the first tablet-only Android update – was released, based on Linux kernel 2.6.36. The first device featuring this version, the Motorola Xoom tablet, was released on 24 February 2011.\Changes included:[43]
  • Optimized tablet support with a new virtual and “holographic” user interface
  • Added System Bar, featuring quick access to notifications, status, and soft navigation buttons, available at the bottom of the screen
  • Added Action Bar, giving access to contextual options, navigation, widgets, or other types of content at the top of the screen
  • Multitasking support - tapping Recent Apps in the System Bar allows users to see snapshots of the tasks underway and quickly jump from one app to another
  • Redesigned keyboard, making typing fast, efficient and accurate on larger screen sizes
  • Simplified, more intuitive copy/paste interface
  • Multiple browser tabs replacing browser windows, plus form auto-fill and a new “incognito” mode allowing anonymous browsing
  • Quick access to camera exposure, focus, flash, zoom, front-facing camera, time-lapse, and more
  • Ability to view albums and other collections in full-screen mode in Gallery, with easy access to thumbnails for other photos
  • New two-pane Contacts UI and Fast Scroll to let users easily organize and locate contacts
  • New two-pane Email UI to make viewing and organizing messages more efficient, allowing users to select one or more messages
  • Support for video chat using Google Talk
  • Hardware acceleration
  • Support for multi-core processors
  • Ability to encrypt all user data


3.1

The 3.1 SDK was released on 10 May 2011. Changes included:
  • UI refinements
  • Connectivity for USB accessories
  • Expanded Recent Apps list
  • Resizable Home screen widgets
  • Support for external keyboards and pointing devices
  • Support for joysticks and gamepads
  • Support for FLAC audio playback
  • High-performance Wi-Fi lock, maintaining high-performance Wi-Fi connections when device screen is off
  • Support for HTTP proxy for each connected Wi-Fi access point


3.2

The 3.2 SDK was released on 15 July 2011, first appearing on Huawei's MediaPad tablet.
 Changes included:
  • Improved hardware support, including optimisations for a wider range of tablets
  • Increased ability of apps to access files on the SD card, e.g. for synchronisation
  • Compatibility display mode for apps that have not been optimized for tablet screen resolutions
  • New display support functions, giving developers more control over display appearance on different Android devices


3.2.1

The Android 3.2.1 update was released on 20 September 2011, and included a number of amendments:
  • Bug fixes and minor security, stability and Wi-Fi improvements
  • Update to Android Market with automatic updates and easier-to-read Terms and Condition text
  • Update to Google Books
  • Improved Adobe Flash support in browser
  • Improved Chinese handwriting prediction

]3.2.2

The 3.2.2 update was released on 30 August 2011, and included bug fixes and other minor improvements for the Motorola Xoom 4G.

Android 2.3.x Gingerbread features


2.3

On 6 December 2010, the Android 2.3 (Gingerbread) SDK was released, based on Linux kernel 2.6.35.
 Changes included:
  • Updated user interface design with increased simplicity and speed
  • Support for extra-large screen sizes and resolutions (WXGA and higher)
  • Native support for SIP VoIP internet telephony
  • Faster, more intuitive text input in virtual keyboard, with improved accuracy, better suggested text and voice input mode
  • Enhanced copy/paste functionality, allowing users to select a word by press-hold, copy, and paste
  • Support for Near Field Communication (NFC), allowing the user read an NFC tag embedded in a poster, sticker, or advertisement
  • New audio effects such as reverb, equalization, headphone virtualization, and bass boost
  • New Download Manager, giving users easy access to any file downloaded from the browser, email, or another application
  • Support for multiple cameras on the device, including a front-facing camera, if available
  • Support for WebM/VP8 video playback, and AAC audio encoding
  • Improved power management with a more active role in managing apps that are keeping the device awake for too long
  • Enhanced support for native code development
  • Switched from YAFFS to ext4 on newer devices
  • Audio, graphical, and input enhancements for game developers
  • Concurrent garbage collection for increased performance
  • Native support for more sensors (such as gyroscopes and barometers)


2.3.3

Released on 9 February 2011, Android 2.3.3 included several improvements and API fixes.


2.3.4

Version 2.3.4 introduced support for voice or video chat using Google Talk.


2.3.5

Released on 25 July 2011, Android 2.3.5 included a number of amendments:
  • Improved network performance for the Nexus S 4G, among other fixes and improvements
  • Fixed Bluetooth bug on Samsung Galaxy S
  • Improved Gmail application
  • Shadow animations for list scrolling
  • Camera software enhancements
  • Improved battery efficiency


2.3.6

This version fixed a voice search bug.


2.3.7

Android 2.3.7 introduced Google Wallet support for the Nexus S 4G.

Android 2.2.x Froyo features


2.2

On 20 May 2010, the Android 2.2 (Froyo) SDK was released, based on Linux kernel 2.6.32.[ Its features included:
  • Speed, memory, and performance optimizations[
  • Additional application speed improvements, implemented through JIT compilation
  • Integration of Chrome's V8 JavaScript engine into the Browser application
  • Support for the Android Cloud to Device Messaging (C2DM) service, enabling push notifications
  • Improved Microsoft Exchange support, including security policies, auto-discovery, GAL look-up, calendar synchronization and remote wipe
  • Improved application launcher with shortcuts to Phone and Browser applications
  • USB tethering and Wi-Fi hotspot functionality
  • Added an option to disable data access over mobile network
  • Updated Market application with batch and automatic update features
  • Quick switching between multiple keyboard languages and their dictionaries
  • Voice dialing and contact sharing over Bluetooth
  • Support for numeric and alphanumeric passwords
  • Support for file upload fields in the Browser application
  • Support for installing applications to the expandable memory
  • Adobe Flash support
  • Support for extra-high-PPI screens (320 ppi), such as 4" 720p

2.2.1

The Android 2.2.1 update was released on 18 January 2011, and included a number of bug fixes, security updates, and performance improvements.


2.2.2

The Android 2.2.2 update was released on 22 January 2011, and fixed minor bugs, including SMS rooting issues that affected the Nexus One.

2.2.3

The Android 2.2.3 update was released on 21 November 2011, and consisted of two security patches.