Wednesday, 13 March 2013

Apk to code

http://blog.inyourbits.com/2012/11/extending-existing-android-applications.html

http://blog.inyourbits.com/2012/12/extending-existing-android-applications.html


http://code.google.com/p/android-apktool/downloads/list

http://java.decompiler.free.fr/?q=jdgui

Tuesday, 12 March 2013

Route Map

http://mobiforge.com/developing/story/using-google-maps-android

http://csie-tw.blogspot.in/2009/06/android-driving-direction-route-path.html
http://www.anddev.org/route_-_improved_google_driving_directions-t1892.html

http://stackoverflow.com/questions/2023669/j2me-android-blackberry-driving-directions-route-between-two-locations

http://code.google.com/p/j2memaprouteprovider/source/browse/trunk/J2MEMapRouteAndroidEx/#J2MEMapRouteAndroidEx%2Fsrc%253Fstate%253Dclosed   (Code)

Monday, 11 March 2013

IntentService

http://stackoverflow.com/questions/5682632/android-httpclient-as-a-backgroundservice

http://www.vogella.com/articles/AndroidServices/article.html

http://www.mysamplecode.com/2011/10/android-intentservice-example-using.html


http://stackoverflow.com/questions/4443278/toast-sending-message-to-a-handler-on-a-dead-thread

BackgroundUrlhit continously run in service

http://stackoverflow.com/questions/4443278/toast-sending-message-to-a-handler-on-a-dead-thread

AndroidNotifyService.java


import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class AndroidNotifyService extends Activity {
    /** Called when the activity is first created. */
    Intent intent;
    NotifyService notifyService;
    PendingIntent pintent;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button buttonStartService = (Button)findViewById(R.id.startservice);
        Button buttonStopService = (Button)findViewById(R.id.stopservice);
       
        buttonStartService.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
               
                /*intent = new Intent(AndroidNotifyService.this, NotifyService.class);
                startService(intent);
                */
               
                /*Calendar cur_cal = Calendar.getInstance();
                cur_cal.setTimeInMillis(System.currentTimeMillis());
                cur_cal.add(Calendar.SECOND, 50);
                Log.d("Testing", "Calender Set time:"+cur_cal.getTime());
               
                //Intent intent = new Intent(AndroidNotifyService.this, NotifyService.class);
                intent = new Intent(AndroidNotifyService.this, NotifyService.class);
                pintent = PendingIntent.getService(AndroidNotifyService.this, 0, intent, 0);
                AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(), 1*1000, pintent);
                */
               
                System.out.println("clicked");
                /*
                Intent i = new Intent ("com.example.serviceexample.BackgroundConnectionService");
                startService(i);*/
               
                Calendar cur_cal = Calendar.getInstance();
                cur_cal.setTimeInMillis(System.currentTimeMillis());
                cur_cal.add(Calendar.SECOND, 50);
                Log.d("Testing", "Calender Set time:"+cur_cal.getTime());
               
                //Intent intent = new Intent(AndroidNotifyService.this, NotifyService.class);
                intent = new Intent("com.example.serviceexample.BackgroundConnectionService");
                pintent = PendingIntent.getService(AndroidNotifyService.this, 0, intent, 0);
                AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
                alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(),1000, pintent);
               
               
               
            }});
       
        buttonStopService.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View arg0) {
               
                //stopService(intent);
                /*AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
                alarmManager.cancel(pintent);
                */
            }});
       

    }
}



BackgroundConnectionService.java



package com.example.serviceexample;

import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import android.app.IntentService;
import android.content.Intent;


public class BackgroundConnectionService extends IntentService {

    String res="";
    public BackgroundConnectionService() {
        // Need this to name the service
        super ("ConnectionServices");
        System.out.println("t1");
    }

    @Override
    protected void onHandleIntent(Intent arg0) {
       
        BasicNameValuePair nameValuePair = new BasicNameValuePair("UserID", "v3390");
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
        nameValuePairList.add(nameValuePair);
       
        URLHit url = new URLHit("http://121.242.232.139:8082/Sales_Service/predocs", nameValuePairList);
        res = url.hitresponse();
        System.out.println("Response: "+res);
    }
}



AndroidManifest.xml


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

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

    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".AndroidNotifyService"
            android:label="@string/title_activity_android_notify_service"
            android:screenOrientation="portrait"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       
       
        <service android:name="com.example.serviceexample.BackgroundConnectionService">
            <intent-filter>
                <action android:name="com.example.serviceexample.BackgroundConnectionService" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>
       

       
    </application>

</manifest>

preferences

http://viralpatel.net/blogs/android-preferences-activity-example/

Message notificaton

http://vimaltuts.com/android-tutorial-for-beginners/android-notification-status-bar-example

Sunday, 10 March 2013

Service

http://marakana.com/forums/android/examples/60.html

Carousel

http://www.codeproject.com/Articles/146145/Android-3D-Carousel

http://developer.digitalaria.com/devguide/gama/en/gama/carousel_android.php

http://mobile.smashingmagazine.com/2013/02/01/android-carousel-design-pattern/

https://www.google.co.in/search?um=1&hl=en&q=carousel%20in%20android&bav=on.2,or.r_qf.&bvm=bv.43287494,d.bmk&biw=1152&bih=727&ie=UTF-8&sa=N&tab=iw&ei=g1Y9Ud-eMMzjrAe24YDADg

Wednesday, 6 March 2013

webservice

http://stackoverflow.com/questions/1048310/how-to-call-a-net-web-service-from-android

Tuesday, 5 March 2013

Map

http://www.chupamobile.com/tutorial/details/53


https://developers.google.com/maps/documentation/android/v1/hello-mapview

http://androidcookbook.com/Recipe.seam;jsessionid=DF09DFBA75CBDF36240A8B252FA70F69?recipeId=2338


http://blog.doityourselfandroid.com/2010/12/25/understanding-locationlistener-android/

http://www.javacodegeeks.com/2010/09/android-location-based-services.html

http://developer.android.com/training/basics/location/locationmanager.html

http://about-android.blogspot.in/2010/03/sample-google-map-driving-direction.html (Tracking)

http://stackoverflow.com/questions/4408671/android-draw-route-on-a-mapview-with-twoo-poi-s (Path route) 

http://stackoverflow.com/questions/4408671/android-draw-route-on-a-mapview-with-twoo-poi-s

http://stackoverflow.com/questions/2023669/j2me-android-blackberry-driving-directions-route-between-two-locations/2023685#2023685


http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception


Monday, 4 March 2013

MD5 - for google Map

C:\>keytool -v -list -keystore C:\Android\debug.keystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: Aug 10, 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: 5024c471
Valid from: Fri Aug 10 13:51:05 IST 2012 until: Sun Aug 03 13:51:05 IST 2042
Certificate fingerprints:         Signature algorithm name: SHA1withRSA
         Version: 3


*******************************************
*******************************************

ADB

http://mobile.tutsplus.com/tutorials/android/android-adb-quick-guide/

Sunday, 3 March 2013

getcolumn Names in sqlite

       SqliteHelper sh = new SqliteHelper(Mainmenuactivity);
        Cursor c = sh.readvalues("information");
        String []names = c.getColumnNames();
        StringBuffer str=new StringBuffer();
       
        for(int i=0;i<names.length;i++){
           
            str.append(names[i]);
           
        }
       
        Toast.makeText(Mainmenuactivity, str.toString(),Toast.LENGTH_SHORT).show();

Alter Table - (delete colum )

BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;

CustomListview

RowItem.java
 ---------------

public class RowItem {
   
   
    private int imageId;
    private String title;
    private String desc;
   
    public RowItem(int imageId, String title, String desc)
    {
        this.imageId = imageId;
        this.title = title;
        this.desc = desc;
    }
   
    public int getImageId() {
        return imageId;
    }
    public void setImageId(int imageId) {
        this.imageId = imageId;
    }
    public String getDesc() {
        return desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
   
    @Override
    public String toString() {
        return title + "\n" + desc;
    }
   
   

}



List_litem.xml
--------------
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <ImageView
        android:id="@+id/icon"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:contentDescription="@string/image"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:src="@drawable/ic_launcher"
         />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/icon"
        android:paddingBottom="10dp"
        android:textColor="#CC0033"
        android:textSize="16dp"
        android:text="Title"
         />

    <TextView
        android:id="@+id/desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/title"
        android:layout_toRightOf="@+id/icon"
        android:textColor="#3399FF"
        android:textSize="14dp"
        android:text="Desc"
        />
</RelativeLayout>

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="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
     />
   
</LinearLayout>






CustomListViewAdapter.java
----------------------------

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomListViewAdapter extends ArrayAdapter<RowItem> {

    Context context;
   
    public CustomListViewAdapter(Context context, int resourceId,List<RowItem> items) {
        super(context, resourceId,items);
        this.context = context;
    }
   
    private class ViewHolder {
       
        TextView txtDesc;
        TextView txtTitle;
        ImageView imageView;
    }
   
    public View getView(int position, View convertView, ViewGroup parent) {
       
        ViewHolder holder = null;
        RowItem rowItem = getItem(position);
        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
       
        if (convertView == null) {
           
            convertView = mInflater.inflate(R.layout.list_item, null);
           
            holder = new ViewHolder();
            holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
            holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
            holder.imageView = (ImageView) convertView.findViewById(R.id.icon);
            convertView.setTag(holder);
           
        }
        else{
           
            holder = (ViewHolder) convertView.getTag();
        }
       
            holder.txtDesc.setText(rowItem.getDesc());
            holder.txtTitle.setText(rowItem.getTitle());
            holder.imageView.setImageResource(rowItem.getImageId());

        return convertView;
    }

}

MainActivity.java
---------------------
import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnItemClickListener {

   
    public static final String[] titles = new String[] { "Strawberry",
        "Banana", "Orange", "Mixed" };

    public static final String[] descriptions = new String[] {
            "It is an aggregate accessory fruit",
            "It is the largest herbaceous flowering plant", "Citrus Fruit",
            "Mixed Fruits" };

    public static final Integer[] images = { R.drawable.ic_launcher,
        R.drawable.ic_launcher, R.drawable.ic_launcher, R.drawable.ic_launcher };
   
   
    ListView listView;
    List<RowItem> rowItems;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
       
        rowItems = new ArrayList<RowItem>();
       
        for (int i = 0; i < titles.length; i++) {
           
            RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
            rowItems.add(item);
        }
       
        listView = (ListView) findViewById(R.id.list);
        CustomListViewAdapter adapter = new CustomListViewAdapter(this,R.layout.list_item, rowItems);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
       
        Toast.makeText(getApplicationContext(),"Item " + (position + 1) + ": " + rowItems.get(position),Toast.LENGTH_SHORT).show();
       
    }
}

SQLite Class

Calling from Main class:

Mainactivity.class
SqliteHelper sh=new SqliteHelper(context);
sh.getWritableDatabase();
sh.close();



import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;

public class SqliteHelper extends SQLiteOpenHelper
{

    Context context;
    String columnNames[];
    private static final int DATABASE_VERSION = 1;
    private static final String DATABASE_NAME = "example.db";
    String query="Create table information(ID INTEGER PRIMARY KEY,name1 TEXT,name1 TEXT,name1 TEXT,name1 TEXT,name1 TEXT)";
    ContentValues values1;
   
    public SqliteHelper(Context context)
    {
        super(context, DATABASE_NAME , null , DATABASE_VERSION);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Toast.makeText(context,"Database created", Toast.LENGTH_SHORT).show();
        db.execSQL(query);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
       
        Toast.makeText(context,"Database Updated", Toast.LENGTH_SHORT).show();
        db.execSQL("DROP TABLE IF EXISTS information");
        onCreate(db);

    }
    public void insertvalues(String tablename,ContentValues values) {
       
        SQLiteDatabase db = this.getWritableDatabase();
        this.values1 = values;
        //db.beginTransaction();
        db.insert(tablename, null, values1);
        //db.endTransaction();
        Toast.makeText(context,values1.get("BankName")+"Added ", Toast.LENGTH_SHORT).show();
        //db.close(); // Closing database connection
    }
   
    public Cursor readvalues(String tablename) {
       
        SQLiteDatabase db = this.getReadableDatabase();
   
        //db.beginTransaction();
        Cursor  cursor = db.rawQuery("SELECT * FROM information" ,null);
        //db.endTransaction();
        Log.i("tag", "ColunmName:"+cursor. getColumnName(1));
        return cursor;
    }
   
    public void delete_value(String tablename,String columnname,int value)
    {
        SQLiteDatabase db = this.getWritableDatabase();
        //information", "BankName"
        Log.i("deletequery", "DELETE FROM information WHERE ID='"+value+"'");
        db.execSQL("DELETE FROM information WHERE ID='"+value+"'");
       
    }
   
   
     public boolean Update(String tablename, ContentValues values,int where){

            SQLiteDatabase db = this.getWritableDatabase();
            Log.i("Update", ":"+where);
            return db.update(tablename, values, "ID='"+where+"'", null) > 0;

            // Inserting Row
            //db.update(tablename, values, "BankName='"+value+"'", null);
            // Closing database connection
           
           
           
       }
}

corner for Edittext

Border.xml (in Drawable Folder)



<?xml version="1.0" encoding="UTF-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <stroke android:width="2dp"
            android:color="#FF0000" />
    <padding
            android:left="2dp"
            android:top="4dp"
            android:right="2dp"
            android:bottom="4dp" />
   
    <corners
            android:radius="5dp" />
    <solid
            android:color="#FFFFFF"/>
   
</shape>





 Main.xml


<TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:background="@drawable/border"
        android:visibility="visible"
        >

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:hint="Username"
                android:singleLine="true"
                android:textColor="@drawable/focuscolor" />
        </TableRow>

        <View
            android:layout_height="2dp"
            android:background="#FF0000" />

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:hint="Password"
                android:singleLine="true"
                android:textColor="@drawable/focuscolor" />
        </TableRow>
    </TableLayout>