Tuesday, July 9, 2013

BOOT_COMPLETED BroadcastReceiver In Android

Android BootReciever


Many a time We need to perform some task when Device/Mobile finish it's booting process.
For Example giving notification that "SIM has been Changed" etc.

For this we need a Broadcast  receiver that should receive "BOOT_COMPLETED" broadcast. We must know  that when a device finishes booting Android System sends "BOOT_COMPLTED" broadcast.

Registering the BootReciever in android manifest file


<receiver android:name=".BootReceiver">
                        <intent-filter>
                                <action android:name="android.intent.action.BOOT_COMPLETED" />
                                <category android:name="android.intent.category.HOME" />
                        </intent-filter>
   </receiver>



and do not forget to add the following permission in manifest .

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

this permission is required to listen/reverie the BOOT_COMPLETED action



BootRecieAndroidvr In

BootReceiver.java  

 

public class BootReceiver extends BroadcastReceiver
{
      
            public void onReceive(Context context, Intent intent)
            {
               
                   // Your code to execute when Boot Completd

                   Toast.makeText(context, "Booting Completed", Toast.LENGTH_LONG).show();
            }
}
                     
           
The onRecieve() method of BootReceiver will execute when boot completes, so wee need to write the code inside onReceive() method.





Thursday, July 4, 2013

What is Android

What is Android

    Android is a  Linux-based operating system

•     Android is  designed primarily for touchscreen mobile devices such as smartphones and tablet computers.
•   Android is  currently developed by Google.
•    Android was Initially developed by Android Inc, whom Google financially backed and later purchased in 2005.
•     The Android Software Development Kit (Android SDK) provides all necessary tools to develop Android applications. This includes a compiler, debugger and a device emulator, as well as its own virtual machine to run Android programs

Android is open source and Google releases the code under the Apache License


Android applications run in a sandbox, an isolated area of the system that does not have access to the rest of the system's resources, unless access permissions are explicitly granted by the user when the application is installed. Before installing an application, the Play Store displays all required permissions
The source code for Android is available under free and open source software licenses. Google publishes most of the code (including network and telephony stacks) under the Apache License version 2.0 


The version history of the Android mobile operating system began with the release of the Android beta in November 2007. The first commercial version, Android 1.0, was released in September 2008

Below is List of Android Version and API Level

 
VersionCode nameRelease date          API level
4.2     Jelly BeanNovember 13, 2012              17
4.1.xJelly BeanJuly 9, 2012                      16
4.0.xIce Cream SandwichDecember 16, 2011      15
3.2HoneycombJuly 15, 2011      13
3.1HoneycombMay 10, 2011      12
2.3.3–2.3.7GingerbreadFebruary 9, 2011     10
2.3–2.3.2GingerbreadDecember 6, 2010      9
2.2FroyoMay 20, 2010       8
2.0–2.1EclairOctober 26, 2009      7
1.6DonutSeptember 15, 2009               4





The Android Development Tutorials blog contains Basic as well as Advanced android tutorials.Go to Android Development Tutorials to get list of all Android Tutorials.

 

 

More Android Topics

New Advance Topics:
Android ImageSwitcher                    Android TextSwitcher                                Android ViewFlipper
Android Gesture Detector               Handling/Detecting Swap Events                Gradient Drawable
Detecting Missed Calls                    Hide Title Bar                                           GridView Animation

 Beginning With Android
      Android : Introduction                                                              Configuring Eclipse for Android Development
     Creating Your First Android Project                                           Understanding Android Manifest File of your android app

 Advance Android Topics                                                              Customizing Android Views


Working With Layouts                                                                Working With Views

Understanding Layouts in Android                                                   Using Buttons and EditText in Android
Working with Linear Layout (With Example)                                     Using CheckBoxes in Android
Nested Linear Layout (With Example)                                              Using AutoCompleteTextView in Android                                                                                          Grid View
Relative Layout In Android                                                               ListView
Table Layout                                                                                   Android ProgressBar
Frame Layout(With Example)                                                          Customizing ProgressBar
Absolute Layout                                                                             Customizing Radio Buttons
Grid Layout                                                                                    Customizing Checkboxes In Android

Android Components                                                                 Dialogs In Android

Activity In Android                                                                    Working With Alert Dialog
Activity Life Cycle                                                                    Adding Radio Buttons In Dialog
Starting Activity For Result                                                       Adding Check Boxes In Dialog
Sending Data from One Activity to Other in Android                    Creating Customized Dialogs in Android
Returning Result from Activity                                                   Creating Dialog To Collect User Input
Android : Service                                                                     DatePicker and TimePickerDialog
BroadcastReceiver                                                                   Using TimePickerDialog and DatePickerDialog In android

Menus In Android                                                                ListView:
Creating Option Menu                                                               Populating ListView With DataBase
Creating Context Menu In Android                                              Populating ListView with ArrayList
                                                                                               ListView with Custom Adapter

Toast                                                                                      Working With SMS
Customizing Toast In Android                                                       How to Send SMS in Android
Customizing the Display Time of Toast                                        How To Receive SMS
Customizing Toast At Runtime                                                  Accessing Inbox In Android
Adding Image in Toast
Showing Toast for Longer Time


TelephonyManager                                                            Storage: Storing Data In Android
Using Telephony Manager In Android                                          SharedPreferences In Android
                                                                                              Reading and Writing files to Internal Stoarage
Working With Incoming Calls                                             DataBase
How To Handle Incoming Calls in Android                                Working With Database in Android
How to Forward an Incoming Call In Android                            Creating Table In Android
CALL States In Android                                                          Inserting, Deleting and Updating Records In Table in Android


Miscellaneous
Notifications In Android
How To Vibrate The Android Phone
Sending Email In Android
Opening a webpage In Browser
How to Access PhoneBook In Android
Prompt User Input with an AlertDialog





Wednesday, July 3, 2013

Price Chopper Supermarkets partners with Zavers by Google to reward their most loyal shoppers

Since its launch in January, Zavers by Google has partnered with leading regional supermarkets, like D’Agostino, BI-LO/Winn-Dixie and Associated Food Stores, to reward customers with relevant coupons. The digital coupon solution also helps retailers and manufacturers increase shopper spend and basket size.

Price Chopper, an innovative 81-year-old supermarket chain based in New York, worked with Zavers to engage their loyal shoppers in a new way, and saw significant results. Price Chopper was looking to optimize their coupon marketing campaigns and deliver more effective coupons to their customers’ rewards cards. After researching multiple digital coupon solutions, Price Chopper teamed up with Zavers by Google to seamlessly integrate their website and mobile app with the technology to load coupons directly to customers’ rewards cards.

“Digital coupons make it easier for shoppers to get savings at the moment they’re deciding what to buy. Plus, with automatic redemption at checkout, our cashiers don’t have to spend time scanning paper coupons,” says Heidi Reale, Price Chopper’s Director of Shopper and Digital Marketing.

After implementing Zavers by Google, Price Chopper saw significant gains in basket size, trip frequency, and weekly spend amongst its best customers. Internal analysis revealed that loyal shoppers who spent 50 percent of their share-of-wallet with Price Chopper also represented 43 percent of all their Zavers digital coupon users, which meant that these shoppers make up a valuable segment of their customers.

Furthermore, a Price Chopper comparison analysis of shopper spending habits showed that among shoppers who engaged with Zavers e-coupons, the average total monthly spend of active customers increased by 10 percent.

“We are very happy with the results so far,” Reale says. “We see e-coupons as a way to reward our best shoppers, the ones who spend the most with us and visit us the most. With Zavers by Google, we don’t simply deliver a coupon to someone’s
card. We deliver it more effectively in a way that generates a better ROI for both manufacturers and retailers.”

To learn more about Price Chopper’s success with Zavers by Google, download the full case study. Visit google.com/zavers to learn more about Zavers’ digital couponing solution or contact our sales team at g.co/contact-zavers.

Posted by Jenny Liu, Product Marketing Manager, Zavers by Google

Tuesday, July 2, 2013

Android Live Wallpaper Tutorial

Live wallpapers   - are  richer, animated, interactive backgrounds on Homescreen.

In this post I will describe step by step "How to Create LiveWallpaper " .

  The Android Development Tutorials blog contains Basic as well as Advanced android tutorials.Go to Android Development Tutorials to get list of all Android Tutorials.

 

Android Live Wallpaper Example


In this example I have created a LiveWallpaper in which a Fish  is moving left to right.
The example is too simple and has been described in manner that you can easily  understand.

Android Live  Wallpaper


How to create a Live Wallpaper

Step 1: create a xml file which will describe your wallpaper.
Step 2: edit your manifest file add service and feature.
Step 3: create a service class which extends WallpaperService class.


Step 1:  create a xml folder inside res folder.
              inside xml folder create mywallpaper.xml file

             <?xml version="1.0" encoding="UTF-8"?>
            <wallpaper
                     xmlns:android="http://schemas.android.com/apk/res/android"
                     android:thumbnail="@drawable/fish"
                     android:description="@string/wallpaper_description" 
            />

here thumbnail is the image that will be shown in list of livewallpapers and description attribute is the description of your live wallpaper.

Also add following in your string.xml file inside values folder
<string name="wallpaper_description">Fish Aquarium</string>

Step 2: Edit your Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.livewallpapertutorial"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

     <uses-feature
        android:name="android.software.live_wallpaper"
        android:required="true" >
    </uses-feature>


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <service
            android:name="LiveWallpaperService"
            android:enabled="true"
            android:label="Wallpaper Example "
            android:permission="android.permission.BIND_WALLPAPER" >
            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" >
                </action>
            </intent-filter>

            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/mywallpaper" >
            </meta-data>

        </service>

    </application>

</manifest>



Step 3: create a service class which extends  WallpaperService.

this class is the base class for all live wallpapers in the system. You must implement the   onCreateEngine()   method .
The Engine class defines the life cycle methods, as for example onCreate(), onSurfaceCreated(), onVisibilityChanged(), onOffsetsChanged(), onTouchEvent() and onCommand()


public class LiveWallpaperService extends WallpaperService
{
                int x,y;
               
                public void onCreate()
                {
                        super.onCreate();
                }

                public void onDestroy()
                {
                        super.onDestroy();
                }

                public Engine onCreateEngine()
                {
                        return new MyWallpaperEngine();
                }

                class MyWallpaperEngine extends Engine
                {

                        private final Handler handler = new Handler();
                        private final Runnable drawRunner = new Runnable() {
                            @Override
                            public void run() {
                                draw();
                            }
                        };
                        private boolean visible = true;
                        public Bitmap image1,backgroundImage;

                        MyWallpaperEngine()
                        {
                                 // get the fish and background image references
                                image1 = BitmapFactory.decodeResource(getResources(),R.drawable.fish);
                                backgroundImage = BitmapFactory.decodeResource(getResources(),R.drawable.background);
                                x=-130; // initialize x position
                                y=200;  // initialize y position
                               
                        }


                        public void onCreate(SurfaceHolder surfaceHolder)
                        {
                                super.onCreate(surfaceHolder);
                        }

                        @Override
                        public void onVisibilityChanged(boolean visible)
                        {
                                this.visible = visible;
                                // if screen wallpaper is visible then draw the image otherwise do not draw
                                if (visible)
                                {
                                    handler.post(drawRunner);
                                }
                                else
                                {
                                    handler.removeCallbacks(drawRunner);
                                }
                        }

                        @Override
                        public void onSurfaceDestroyed(SurfaceHolder holder)
                        {
                                super.onSurfaceDestroyed(holder);
                                this.visible = false;
                                handler.removeCallbacks(drawRunner);
                        }

                        public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels)
                        {
                                draw();
                        }

                        void draw()
                        {
                                final SurfaceHolder holder = getSurfaceHolder();
                 
                                Canvas c = null;
                                try
                                {
                                        c = holder.lockCanvas();
                                        // clear the canvas
                                        c.drawColor(Color.BLACK);
                                        if (c != null)
                                        {
                                                // draw the background image
                                                c.drawBitmap(backgroundImage, 0, 0, null);
                                                // draw the fish
                                                c.drawBitmap(image1, x,y, null);
                                                // get the width of canvas
                                                int width=c.getWidth();
                                               
                                                // if x crosses the width means  x has reached to right edge
                                                if(x>width+100)
                                                {  
                                                        // assign initial value to start with
                                                        x=-130;
                                                }
                                                // change the x position/value by 1 pixel
                                                x=x+1;
                                        }
                                 }
                                finally
                                {
                                        if (c != null)
                                               holder.unlockCanvasAndPost(c);
                                }

                                handler.removeCallbacks(drawRunner);
                                if (visible)
                                {
                                          handler.postDelayed(drawRunner, 10); // delay 10 mileseconds
                                }   

                        }
                }
}


Run the application and set the Wallpaper.( Long Press on Screen ->Set Wallpaper -> HomeScreen -> Live Wallpapers -> select your Live wall paper)

Android Live  Wallpaper




 

More Android Topics

New Advance Topics:
Android ImageSwitcher                    Android TextSwitcher                                Android ViewFlipper
Android Gesture Detector               Handling/Detecting Swap Events                Gradient Drawable
Detecting Missed Calls                    Hide Title Bar                                           GridView Animation

 Beginning With Android
      Android : Introduction                                                              Configuring Eclipse for Android Development
     Creating Your First Android Project                                           Understanding Android Manifest File of your android app

 Advance Android Topics                                                              Customizing Android Views


Working With Layouts                                                                Working With Views

Understanding Layouts in Android                                                   Using Buttons and EditText in Android
Working with Linear Layout (With Example)                                     Using CheckBoxes in Android
Nested Linear Layout (With Example)                                              Using AutoCompleteTextView in Android                                                                                          Grid View
Relative Layout In Android                                                               ListView
Table Layout                                                                                   Android ProgressBar
Frame Layout(With Example)                                                          Customizing ProgressBar
Absolute Layout                                                                             Customizing Radio Buttons
Grid Layout                                                                                    Customizing Checkboxes In Android

Android Components                                                                 Dialogs In Android

Activity In Android                                                                    Working With Alert Dialog
Activity Life Cycle                                                                    Adding Radio Buttons In Dialog
Starting Activity For Result                                                       Adding Check Boxes In Dialog
Sending Data from One Activity to Other in Android                    Creating Customized Dialogs in Android
Returning Result from Activity                                                   Creating Dialog To Collect User Input
Android : Service                                                                     DatePicker and TimePickerDialog
BroadcastReceiver                                                                   Using TimePickerDialog and DatePickerDialog In android

Menus In Android                                                                ListView:
Creating Option Menu                                                               Populating ListView With DataBase
Creating Context Menu In Android                                              Populating ListView with ArrayList
                                                                                               ListView with Custom Adapter

Toast                                                                                      Working With SMS
Customizing Toast In Android                                                       How to Send SMS in Android
Customizing the Display Time of Toast                                        How To Receive SMS
Customizing Toast At Runtime                                                  Accessing Inbox In Android
Adding Image in Toast
Showing Toast for Longer Time


TelephonyManager                                                            Storage: Storing Data In Android
Using Telephony Manager In Android                                          SharedPreferences In Android
                                                                                              Reading and Writing files to Internal Stoarage
Working With Incoming Calls                                             DataBase
How To Handle Incoming Calls in Android                                Working With Database in Android
How to Forward an Incoming Call In Android                            Creating Table In Android
CALL States In Android                                                          Inserting, Deleting and Updating Records In Table in Android


Miscellaneous
Notifications In Android
How To Vibrate The Android Phone
Sending Email In Android
Opening a webpage In Browser
How to Access PhoneBook In Android
Prompt User Input with an AlertDialog