Monday, 21 January 2013

Set up to track mobile application downloads for Android

racking app downloads from Google Play doesn't require adding a code snippet. It can be done with no changes to your app's code. Simply follow the steps below


Sign in to your AdWords account at http://adwords.google.com

1. Click the "Tools and Analysis" tab, and then click the "Conversions" tab.
2. Click the "+ Conversion" button.
3. Name your conversion, select "App download" and click "Save and continue". Enter the package name. (You can find your package name by looking up your app in Google Play. It's the part of the base URL that identifies your application:"https://play.google.com/store/apps/details?id=<package_name>")
4. Click "Save and continue".
5. On the next screen, click "Done".
6. Your app downloads conversion data will now start showing up with the rest of your conversion data within 24 hours.
Note: Application download tracking for Android will only work if your links in Click-to-download  or Mobile App Extension ads point directly to the Google Play Store. Third-party tracking URLs are not supported at this time.


                                                    Click-to-download
If you want to make it easier for people to download your mobile app, you can begin by creating a click-to-download ad. This kind of ad allows people to download your app from iTunes or Android market after clicking on your ad.

When you create an ad, you can choose to create a click-to-download ad. When you enter the display URL for the ad, include the URL "itunes.apple.com/" or "play.google.com/store". When the ad is running, the display URL will show that an app can be downloaded from iTunes or Google Play.
If you include a full link to where the app can be downloaded in the "Destination URL" field, Google will automatically find and display the icon that's registered in the iTunes App Store or Google Play.
Example   Android
Display URL: play.google.com/store/
Destination URLs:
Search results page: http://play.google.com/search?q=pname:com.example.appname
App details page: http://play.google.com/store/apps/details?id=com.example.appname
To build the destination URL for Android apps, you'll need the app's "fully qualified Java package name." Once you have the package name, insert it into one of the following URL structures:
1. http://play.google..com/store/search?q=pname:
2. http://play.google.com/store/apps/details?id=pname

For more Detail follow the Following link
http://support.google.com/adwords/answer/1722054/?hl=en
http://support.google.com/adwords/answer/2549053
http://support.google.com/adwords/answer/1722117
http://support.google.com/adwords/answer/1722057





Friday, 18 January 2013

Android Push Notifications using Google Cloud Messaging (GCM)


  At first What is Push Notifications?
It is type of notification which comes from server to android device and it informs user automatically that some information have come from server. So you(user)have to open it and get the detail.
Now coming on topic
Google provides a service named Google Cloud Message (GCM) which allows developers to send data to their applications running on Android devices.
Unlike most solutions which involve polling some server, this service is a "push" service (similar to SMS messages).

GCM replaces the previous service named C2DM. This framework is a modified version of the previous C2DM framework that works with the new service.
Note that new GCM service is simpler than C2DM and doesn't require a special approval from Google.
How to use it ?
You(Developer) should implement three components in order to use this service.

 Client code- The client code which is responsible for registering the specific device and application with Google service and is responsible for handling new messages that arrive.

Web server- When the device registers with Google service it receives a registration id that allows you, the account holder, to send messages to your application running on the user device. The device needs to send this id to a web server that you can access.

Messages sending tool - This is a command line tool that is responsible for fetching the user id from the web server and then sending the message to the device. This is done by sending a request to Google servers.

Reference:-
For more understanding and detail you can visit this  official link. GCM Architectural Overview | Android Developers

Working Flow of GCM
here I am discussing a rough flow  of GCM push Notification:-
1st. 
Android Phone  send it Application id and Sender id  to GCM server for registration.
2nd.
After successful registration GCM server issued  Registration id to Android device. 
3rd
After getting Registration id Android Device sends  it to our server. 
4th
Our Server stored this Registration id  into Data Base for Future Use. 
5th
Now Notification Message.
Whenever Push Notification needed  Our Server send a message to GCM server with Registered Id(i.e stored in our data base).
  After receiving message GCM server sends it to respective Registered Device(by using registration id).  







Tuesday, 15 January 2013

Share Your Laptop's Internet Connection with Your Phone



                        WiFi Ad Hoc enabler for Android

Most traditionally we use our phone  as modem to connect with laptop/PC to use internet connection.  Generally We use Dial-up type connection mode   to use Internet with phone to Laptop and PC.  But in Some cases we need to connect our phone with Laptop to use Internet  i.e the internet available in Laptop, We want to use it in my phone. 
   This is Known as reverse tethering.   we  can accomplish this "reverse tethering" from our Windows PC or Mac to your Android or iPhone device in a couple of ways.



First Approach 

when you enable/open your wifi on Laptop you are setting up an Ad Hoc network on your laptop. By default, Android wont connect to Ad Hoc networks, so these networks won't show up when you search for new wireless connections.

You have to use Third-party Ad Hoc enablers are available for Android, but they have many known problems and incompatibilities. 

If you want to use this third party AD Hoc Network then you have to  "rooted" your device . 
now what is rooted  Android device ? Android rooting is the process of allowing users of smartphones, tablets, and other devices running the Android mobile operating system to attain privileged control (known as "root access") within Android's subsystem.

Rooting is often performed with the goal of overcoming limitations that carriers and hardware manufacturers put on some devices, resulting in the ability to alter or replace system applications and settings, run specialized apps that require administrator-level permissions, or perform other operations that are otherwise inaccessible to a normal Android user.

After rooting your phone you can use any third party AD Hoc Network app to connect to you Phone(Android Device) with your Laptop. 

For more Detail You can visit this linkhttp://code.google.com/p/android-wifi-tether/http://androidtablethacks.com/android-tablet-hacks/how-to-enable-adhoc-wifi-on-android-tablets/http://www.arenddeboer.com/wifi-ad-hoc-enabler-for-android/

Second Approach
Connectify

Connectify is free software that shares a single Wi-Fi connection over Wi-Fi--no need for a second adapter or for your laptop to be wired to the Internet. It's only available for Windows 7 and above, however. 
One of the main advantages of Connectify over the above methods is that the connection is more secure--using WPA2 encryption in Access Point Mode versus the very insecure WEP, as the ad hoc networking modes above do. 

For detail you can follow this linkhttp://www.connectify.me/hotspot/



Tuesday, 8 January 2013

In-app Billing integration in Android

In-app Billing is a Google Play service that lets you sell digital content from inside your applications. You can use the service to sell a wide range of content, including downloadable content such as media files or photos, virtual content such as game levels or potions, premium services and features, and more. You can use In-app Billing to sell products as
  • Standard in-app products (one-time billing), or
  • Subscriptions, (recurring, automated billing)
When you use the in-app billing service to sell an item, whether it's an in-app product or a subscription, Google Play handles all checkout details so your application never has to directly process any financial transactions. Google Play uses the same checkout backend service as is used for application purchases, so your users experience a consistent and familiar purchase flow.

Any application that you publish through Google Play can implement In-app Billing. No special account or registration is required other than an Android Market publisher account and a Google Checkout merchant account.
For more detail on this you can check this link.

Here I have described a sample application that demonstrates how to sell standard in-app products and subscriptions from inside an app .





Gesture example in Android

Gestures allow users to interact with your app by manipulating the screen objects you provide. There is  some type of Gesture used by User to interact to your application

         Type of Gesture                                                          Action 
  1. Touch                      -------------------------------------   press, lift 
  2. Long Press            ---------------------------------    Press, wait, lift
  3. Swipe                     ------------------------------    Press, lift, move 
  4. Drag                                            " "         Long press, move, lift
  5. Double Touch                            " "    Two touches in quick succession
  6. Pinch open                             " "  2-finger press, move outwards, lift
  7. Pinch Close                           " "2-finger press, move inwards, lift
    This the 7 type gesture in Android . For more detail follow this link.         
              

 1. The Touch event is the simple  gesture event  in android. As foe example button click in your app is Touch gesture example. So You have to use clickListner method in android to handle this event for your touch functionality  As for example when  user click/touch on Button(say Login) then You have to listen it and performed needed task.   

2. Long press:-    This is also a touch event and generally used in list view in android . When user click/touch and hold an item from list view then we have to listen this event and open a pop type window. in that window we have to perform some task like Delete, Detail, Copy, paste etc. 
    To listen this event we use this method
list.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                final int arg2, long arg3) {

}
}
 Here list is List View reference. 
3. Swipe :- This is a gesture event for left , right, top  and down movement of touch event by user. You have to detect user movement and based upon that you have to perform required action. For this we have to use SimpleOnGestureListener class in android. it is A convenience class to extend when you only want to listen for a subset of all the gestures i.e up, down, left right motion of user. 
Creating a project  for Swipe Gesture 
Create a new Android project and named it GestureApp. By default you get MainActiviuty.java  put the following code inside that 
public class MainActivity extends Activity implements SimpleGestureListener {

private SimpleGestureFilter detector;

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

    detector = new SimpleGestureFilter(this,this);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    // TODO Auto-generated method stub
       this.detector.onTouchEvent(ev);
       return super.dispatchTouchEvent(ev);
}

@Override
public void onSwipe(int direction) {
    // TODO Auto-generated method stub
    String str = "";

      switch (direction) {

      case SimpleGestureFilter.SWIPE_RIGHT : str = "Swipe Right";
                                                  newPages();
                                               break;
      case SimpleGestureFilter.SWIPE_LEFT :  str = "Swipe Left";
                                                    newPages();
                                                     break;
      case SimpleGestureFilter.SWIPE_DOWN :  str = "Swipe Down";
                                                    newPages();
                                                     break;
      case SimpleGestureFilter.SWIPE_UP :    str = "Swipe Up";
                                                     newPages();
                                                     break;

      } 
       Toast.makeText(this, str, Toast.LENGTH_SHORT).show();

}

private void newPages() {
     Intent intent  = new Intent(getBaseContext(), Welcome.class);
    startActivity(intent);

}

@Override
public void onDoubleTap() {
    // TODO Auto-generated method stub
     Toast.makeText(this, "Double Tap", Toast.LENGTH_SHORT).show();
     //Double touch

}}
Now create a new class inside a src and named it as SimpleGestureFilter and put following code in it.
public class SimpleGestureFilter extends SimpleOnGestureListener{

public final static int SWIPE_UP    = 1;
 public final static int SWIPE_DOWN  = 2;
 public final static int SWIPE_LEFT  = 3;
 public final static int SWIPE_RIGHT = 4;

 public final static int MODE_TRANSPARENT = 0;
 public final static int MODE_SOLID       = 1;
 public final static int MODE_DYNAMIC     = 2;

 private final static int ACTION_FAKE = -13; //just an unlikely number
 private int swipe_Min_Distance = 100;
 private int swipe_Max_Distance = 200;
 private int swipe_Min_Velocity = 100;

 private int mode  = MODE_DYNAMIC;
 private boolean running = true;
 private boolean tapIndicator = false;

 private Activity context;
 private GestureDetector detector;
 private SimpleGestureListener listener;


 public SimpleGestureFilter(Activity context,SimpleGestureListener sgl) {

  this.context = context;
  this.detector = new GestureDetector(context, this);
  this.listener = sgl; 
 }

 public void onTouchEvent(MotionEvent event){

   if(!this.running)
  return;  

   boolean result = this.detector.onTouchEvent(event); 

   if(this.mode == MODE_SOLID)
    event.setAction(MotionEvent.ACTION_CANCEL);
   else if (this.mode == MODE_DYNAMIC) {

     if(event.getAction() == ACTION_FAKE) 
       event.setAction(MotionEvent.ACTION_UP);
     else if (result)
       event.setAction(MotionEvent.ACTION_CANCEL); 
     else if(this.tapIndicator){
      event.setAction(MotionEvent.ACTION_DOWN);
      this.tapIndicator = false;
     }

   }
   //else just do nothing, it's Transparent
 }

 public void setMode(int m){
  this.mode = m;
 }

 public int getMode(){
  return this.mode;
 }

 public void setEnabled(boolean status){
  this.running = status;
 }

 public void setSwipeMaxDistance(int distance){
  this.swipe_Max_Distance = distance;
 }

 public void setSwipeMinDistance(int distance){
  this.swipe_Min_Distance = distance;
 }

 public void setSwipeMinVelocity(int distance){
  this.swipe_Min_Velocity = distance;
 }

 public int getSwipeMaxDistance(){
  return this.swipe_Max_Distance;
 }

 public int getSwipeMinDistance(){
  return this.swipe_Min_Distance;
 }

 public int getSwipeMinVelocity(){
  return this.swipe_Min_Velocity;
 }


 @Override
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
   float velocityY) {

  final float xDistance = Math.abs(e1.getX() - e2.getX());
  final float yDistance = Math.abs(e1.getY() - e2.getY());

  if(xDistance > this.swipe_Max_Distance || yDistance > this.swipe_Max_Distance)
   return false;

  velocityX = Math.abs(velocityX);
  velocityY = Math.abs(velocityY);
        boolean result = false;

  if(velocityX > this.swipe_Min_Velocity && xDistance > this.swipe_Min_Distance){
   if(e1.getX() > e2.getX()) // right to left
    this.listener.onSwipe(SWIPE_LEFT);
   else
    this.listener.onSwipe(SWIPE_RIGHT);

   result = true;
  }
  else if(velocityY > this.swipe_Min_Velocity && yDistance > this.swipe_Min_Distance){
   if(e1.getY() > e2.getY()) // bottom to up 
    this.listener.onSwipe(SWIPE_UP);
   else
    this.listener.onSwipe(SWIPE_DOWN);

   result = true;
  }

   return result;
 }

 @Override
 public boolean onSingleTapUp(MotionEvent e) {
  this.tapIndicator = true;
  return false;
 }

 @Override
 public boolean onDoubleTap(MotionEvent arg0) {
  this.listener.onDoubleTap();;
  return true;
 }

 @Override
 public boolean onDoubleTapEvent(MotionEvent arg0) {
  return true;
 }

 @Override
 public boolean onSingleTapConfirmed(MotionEvent arg0) {

  if(this.mode == MODE_DYNAMIC){        // we owe an ACTION_UP, so we fake an       
     arg0.setAction(ACTION_FAKE);      //action which will be converted to an ACTION_UP later.                                    
     this.context.dispatchTouchEvent(arg0);  
  }   

  return false;
 }


    static interface SimpleGestureListener{
     void onSwipe(int direction);
     void onDoubleTap();
 }}
Lastly create a welcome.java class inside src folder of your project and put following code in it
public class Welcome extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.welcome);
} }
Now open your layout folder and create a simple welcome.xml file in it like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffccff"
    android:orientation="vertical" >
    <TextView 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:gravity="center"
        android:text="Welcome saurabh"
        android:textSize="18dp"/>

</LinearLayout>
Finally your manifest looks like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="yourApppackageName.com"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:icon="@drawable/gesture"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Welcome"/>
</application>
All is well now your GestureApp is ready for launch. Now run it on Emulator or on real device and find the magic of  Swipe Gesture of Android 
      Happy Coding !!!

Build a Custom Kernel Module for Android

Hi Guys!!!Hope you are doing well !!!. Today I will describe how you can write a custom kernel module(Hello world) for Android and load it a...