Wednesday, 11 June 2014

Simple PushNotification in ANdroid Programmatically

when I click the button, notification will come on status bar in android mobile..

Ex: 1
//---------------------------------------------------------------------------------------------
package com.example.testing1;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivityPushNotification extends Activity {
   
    NotificationManager notifManagerObject ;
    private String title = "Testing Notification Title", body = "Push Notification Messages" ;
    Button btnOne ;
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.push_notification);
       
        btnOne = (Button) findViewById(R.id.button1) ;
       
       
        btnOne.setOnClickListener(new OnClickListener() {
            @SuppressWarnings("deprecation")
            @Override
            public void onClick(View v) {
               
                notifManagerObject = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE) ;
               
                @SuppressWarnings("deprecation")
                Notification nofity = new Notification(R.drawable.ic_launcher, title, 5) ;
               
                PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0) ;
               
                nofity.setLatestEventInfo(MainActivityPushNotification.this, title, body, pendIntent) ;
               
                notifManagerObject.notify(0, nofity) ;
               
               
            }
        }) ;
       
    }
}
//-----------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:text="Button" />

</RelativeLayout>

Get google map api from Google APi Console


using our SHA1 key from windows->pref->android->ddms->copy sha1 key and paste on to google api authentication page with package name using semicolon..

then copy the key and paste it in manifest file...

add more permissions....

Google map api get key procedure while uploading app to play store live

While uploading app to play store live. that time, we need to follow this procedure and get Google Map API key.
Because, normal, app running in testing purpose, we will get the key from eclipse itlself.
via : eclipse->windows->preference->android->Build-> then copy the SHA1 fingerprint 5A:BF:99:54:E3:F0:D2:20:6A:58:0B:16:0C:0B:52:62:B6:5F:9D:4F

D:\Program Files\Java\jdk1.6.0\bin>keytool -list -v -keystore "C:\Users\trainee\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Alias name: androiddebugkey
Creation date: Aug 21, 2012
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 50337779
Valid from: Tue Aug 21 17:26:41 IST 2012 until: Thu Aug 14 17:26:41 IST 2042
Certificate fingerprints:
         MD5:  5A:88:23:FC:2D:BC:4F:E5:BE:7F:16:91:BC:98:1C:F0
         SHA1: 5A:BF:99:54:E3:F0:D2:20:6A:58:0B:16:0C:0B:52:62:B6:5F:9D:4F
         Signature algorithm name: SHA1withRSA
         Version: 3

D:\Program Files\Java\jdk1.6.0\bin>

Cinema News RSS feed websites free access

sample websites

tamilstar.com
http://ibnlive.in.com/rss/
http://cinema.dinamalar.com/rss.php
http://www.nowrunning.com/tamil/
http://www.cinespot.net/gallery/v/Movies/Tamil/?g2_page=2
http://www.indiaglitz.com/channels/tamil/rss.asp
http://www.bharatstudent.com/cafebharat/rssfeed-Tamil-RSS-Feed-3.php

How to restart a emulator or android mobile device using adb tool via command prompt

sometimes, emulator or device get connection disconnected from eclipse to emulator/device.
that time also, its very useful to detect emulator or device again in eclipse using adb(android device bridge).

D:\Android\android-sdk\platform-tools>adb.exe kill-server

D:\Android\android-sdk\platform-tools>adb.exe start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

D:\Android\android-sdk\platform-tools>

How to import the svn code in to eclipse

1. file->new-> others->svn checkout
2 then select create a new reposiroty location
3.then give url details ->next
4 select the source code location ->next
5 give a project name ->finish

How to commit code in first time in svn


1 create new folder rename to projectname
2 select the folder right click select svn checkout
URL : http://000.00.000.000/svn/project name
uname :
password :
3 create the folder tag,branch,trunk
4 copy the source file in trunk
5 right click the project name folder select tortoise svn ->add, once done
6 right click the project name folder select svn commit, succefully completed
7 right click the project name folder select svn update.

Finally check source file updated in svn via http://000.00.000.000/svn/projectname in browser.

Wednesday, 4 June 2014

pass object one activity to another activity using Serialization in android


pass object through bundle android
//--------------------------------------------------------------------------------------------------
public class MainActivityFrom extends Activity {
   
    ArrayList<String> listTest = new ArrayList<String>() ;
    Button btn1 ;
    MySerialization objectSetialization ;
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_second);
       
        listTest.add("CMBT BUS STATION");
       
        Log.v("hari","MainActivityFrom") ;
        btn1 = (Button) findViewById(R.id.button1);
       
       objectSetialization = new MySerialization("krishnanhari",25 , listTest) ;
              
        btn1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
               
                //Passing  MySerialization instance
                Intent mIntent = new Intent(MainActivityFrom.this, MainActivityTo.class);
                Bundle bund = new Bundle() ;
                bund.putSerializable("serialbundle", objectSetialization);
                mIntent.putExtras(bund);
                startActivity(mIntent);
               
            }
        }) ;
    }
}
//--------------------------------------------------------------------------------------------------
import java.io.Serializable;
import java.util.ArrayList;

@SuppressWarnings("serial")
public class MySerialization implements Serializable {
private int age;
private String name;
private ArrayList<String> address;

public MySerialization(String name, int age, ArrayList<String> address) {
    this.name = name;
    this.age = age;
    this.address = address;

}
public int getAge() {
    return age;
}
public String getName() {
    return name;
}
public ArrayList<String> getAddress() {
    if (!(address == null))
        return address;
    else
        return new ArrayList<String>();
}
}
//--------------------------------------------------------------------------------------------------

public class MainActivityTo extends Activity {

    Intent mIntent ;
    Bundle bund = null ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_second);
       
        mIntent = getIntent();
               
        @SuppressWarnings("null")
        MySerialization serial = (MySerialization) mIntent.getSerializableExtra("serialbundle");
       
        bund = mIntent.getExtras();
       
        Log.v("hari","bundle:"+bund.getSerializable("serialbundle"));
       
        Log.v("hari","serial:"+serial.getAge()+"--"+serial.getName()+"--"+serial.getAddress());
             
    }
}
//--------------------------------------------------------------------------------------------------



Tuesday, 3 June 2014

send objects from one activity to another activity through intent using parcelable in android programmatically


Programs :
MainActivityFrom.java
//------------------------------------------------------------------------------------------------
public class MainActivityFrom extends Activity {

    ArrayList<String> list = new ArrayList<String>() ;
    Button btn1 ;
    MyParcealableObjects objects ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_second);
       
        list.add("12 big street,");
        list.add("koyambadu,");
        list.add("chennai");
       
        Log.v("hari","MainActivityFrom") ;
        btn1 = (Button) findViewById(R.id.button1);
       
        objects = new MyParcealableObjects("harikrishnan",26,list) ;
       
        btn1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
               
                //Passing MyOjects instance
                Intent mIntent = new Intent(MainActivityFrom.this, MainActivityTo.class);
                mIntent.putExtra("key", objects);
                startActivity(mIntent);
                               
            }
        }) ;
               
    }
}


//-------------MainActivityTo.java-----------------------------------------------------------------
 public class MainActivityTo extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_second);
      
      
      
        //Bundle data = getIntent().getExtras();
    //  
        //Getting MyParcealableObjects instance
        Intent mIntent = getIntent();
        MyParcealableObjects workorder = (MyParcealableObjects) mIntent.getParcelableExtra("key");
      
        Log.v("hari","workorder:"+workorder.getAge()+"--"+workorder.getName()+"--"+workorder.getAddress());
      
      
    }
}

//------------------------------------------------------------------------------------------------

 package com.example.testing1;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.util.Log;

public class MyParcealableObjects implements Parcelable {

private int age;
private String name;

private ArrayList<String> address;

public MyParcealableObjects(String name, int age, ArrayList<String> address) {
    this.name = name;
    this.age = age;
    this.address = address;

}

public MyParcealableObjects(Parcel source) {
    age = source.readInt();
    name = source.readString();
    address = source.createStringArrayList();
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
  
    Log.v("hari", "writeToParcel:dest:"+dest+"--flags:"+flags);
  
    dest.writeInt(age);
    dest.writeString(name);
    dest.writeStringList(address);

}

public int getAge() {
    return age;
}

public String getName() {
    return name;
}

public ArrayList<String> getAddress() {
    if (!(address == null))
        return address;
    else
        return new ArrayList<String>();
}

public static final Creator<MyParcealableObjects> CREATOR = new Creator<MyParcealableObjects>() {
    @Override
    public MyParcealableObjects[] newArray(int size) {
        return new MyParcealableObjects[size];
    }

    @Override
    public MyParcealableObjects createFromParcel(Parcel source) {
        return new MyParcealableObjects(source);
    }
};

}
//------------------------------------------------------------------------------------------




is it possible to start a thread in Asynctask doinbackground method in android

yes, we can start a new separate thread inside asynctask doinbackground method..

also ,  we can start new asynctask inside another asynctask in android..