Author Archive

Android Push Notification

Push Notification:

Push Notification allows an application to listen for messages being ‘pushed’ to it from the server.
Through Push Notification, our apps can provide uses even when they aren’t running.

Different techniques that could be used for push notifications in android:

1)  Polling:  In this technique device is polling the server on a regular basis to see if there is anything there.

untitled.bmp

Polling that heavily just to check for notification is not a good idea,that would hurt battery life pretty badly after not too long.

2)  Creating a service: In this technique service create a persistent connection to your server.
This will also drain the phone’s battery and it will create problem on server side also if you had more users

3)  SMS: In this method clients gets notified by SMS.

untitled2.bmp

This technique is better as compare to other techniques because:

1) Transfer content as soon as available
2) Save device battery
3) Reduce data traffic for user

Way to implement push via SMS:

1) Your application should add permission in manifest :
Permission:  <uses-permission android:name=”android.permission.RECEIVE_SMS” />
2) and Registers a BroadcastReceiver, either in the manifest XML or in Java, and will get control when the events occur.
<receiver android:name=”.ReceiverClass”>
<intent-filter>
<action android:name=”android.provider.Telephony.SMS_RECEIVED” />
</intent-filter>
</receiver>
3) SMS Header may contain “app port” field that is dedicated range of free usable port numbers.Port handling not yet supported in Android 1.6.
4) You’d have to parse the PDU and get the port from there manually, you can listen to all SMS messages, parse the PDU of each incoming message and see if the destination port
matches the one that you are expecting. But so can other apps.so there’s no way to ensure that just one specific app gets to know about an incoming SMS to a specific port.
5) After matching ports appliaction can handle notification with the help of notification manager.
The problem with this method is that Android currently has no way to cancel the notification that is sent by the messaging app.So for every notification your app gets, the OS will also show a text message.


Android 1.6 Gestures

Android 1.6 platform introduces entirely new gestures framework that finally lets developers build gestures into their apps using the new GestureBuilder tool included in the SDK. Gestures framework provides application developers with a framework for creating, storing, loading, and recognizing gestures and associating them with specific actions.

Need of Gestures:
Touch screens are a great way to interact with applications on mobile devices. With a touch screen, users can easily tap, drag, fling, or slide to quickly perform actions in their favorite applications. But it’s not always that easy for developers. With Android, it’s easy to recognize simple actions, like a swipe, but it’s much more difficult to handle complicated gestures, which also require developers to write a lot of code. In such a situation we can use gestures.This API, located in the new package android.gesture.

We decided to try it out and see how it works. For sample we made a list and used the ‘drag to dustbin’ gesture to delete individual list items.

Step 1: Creating / defining our own gestures using GestureBuilder

GestureBuilder

Step 2: Copy the gesture file created by GestureBuilder from SD card and put it into ‘res/raw’ folder of your project.

Step 3: Write code to handle the event generated by your gesture

step1.png

step2.png

1 Comment more...

  • TechJini Solutions

  • © Copyright 2009 TechJini Solutions Private Limited. All Rights Reserved
    iDream theme by Templates Next | Powered by WordPress