For creating simulator for android galaxy tablet you can follow the below steps.

Step 1: Open Android virtual device manager in Eclipse
Step 2: Create an new Virtual device
Step 3: For target and resolution give the settings for both
Target: Android 3.1 (API 12) (if you don’t have this API level then download the API)
Resolution:  1280*800
That’s it now you can start the virtual device
This is the way you can create simulator for Tablet, now you can test your android application in Tablet
Simulator.

5:32 AM

android.os.NetworkOnMainThreadException

Posted by vijay


Hi..
When I work with android web service project,From starting I used my application in android mobile its working perfectly with webservice,But when I move tablet its shows an below error.
Reason tablet have API 12, Thread policy has changed from the API Level 11
When you are using web service if it take more time then you can get the this type of error..
To overcome this error you have to add the below code on the starting of web service code.

if (android.os.Build.VERSION.SDK_INT > 9) {
                     StrictMode.ThreadPolicy policy =
                           new StrictMode.ThreadPolicy.Builder().permitAll().build();
                     StrictMode.setThreadPolicy(policy);
              }

After I used the above my problem would be solved. I hope it will help someone…
Post your valuable comments here………


Here I would like to share the bit of useful information about android application. When creating android application everyone have need to create or show button in an application. Here I share simple and elegant method to create android button using linear layout.
Ina previous article I wrote to use image in a button, for your reference I mention the link as below


Requirement needed to create
1.       First choose your icon button as in same width and height.
Normally android they are two normally used to create button icon i.e. Linear layout or grid view layout
Here I chose linear layout with horizontal orientation
First needs to create style code in styles.xml files in values folder.
File style.xml
Code:
<style name="DashboardButton">
        <item name="android:layout_gravity">center_vertical</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:drawablePadding">2dp</item>
        <item name="android:textSize">16dp</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">#034486</item>
        <item name="android:background">@drawable/button</item>
         <item name="android:layout_weight">1</item>
         </style>




In your main layout copy the below code and change the image you want to set for the button..
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"      
        android:orientation="vertical" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="40dp" >

            <Button
                android:id="@+id/btn1"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img1"
                android:text="Add"
                android:textSize="14dp" />

            <Button
                android:id="@+id/btn2"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img2”
                android:text="Delete" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="20dp" >

            <Button
                android:id="@+id/btn3"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img3"              
                android:text="edit"
                android:textSize="14dp" />

            <Button
                android:id="@+id/btn4"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img4"              
                android:text="Display"
                android:textSize="14dp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="20dp" >

            <Button
                android:id="@+id/btn5"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img5"
               
                android:text="Store"
                android:textSize="14dp" />
              
        <Button
                android:id="@+id/btn6"
                style="@style/DashboardButton"
                android:drawableTop="@drawable/img6"
                android:text="History"
                android:textSize="14dp" />
     

        </LinearLayout>
    </LinearLayout>


Here store all the images in drawable folder and we set the style for every button as dashboard button
That’s it now you can run view the images are aligned in  your layout
Post your comments here 


Here I would like to share my ideas .How to use login and Logout process in android application.

Website:
Normally when using website we used to store Username and password in session, whenever we want the user details we can easily get from session.
When Logout we simple clear the session and redirect the user to login page.

Android Application:

In android application we can follow the same methods like website. But instead of using session here in android we use ‘ShredPrefrence ‘.SharedPrefrence is like session, we can easily store and get the information from the sharedPrefrence. Also we can easily remove all the details in shared preference.
In Previous article I discuss about store the usage of SharedPrefrence. For your information I provide the link as below.

Steps 1: Login
When user submit the username and password just validate the login details, then store the details in sharedprefrence.
Code:
SharedPreferences myprefs = getApplicationContext()
                                  .getSharedPreferences("user", MODE_PRIVATE);
                     myprefs.edit()
                                  .putString("userid", userid)
                                  .commit();

If you want to check the stored details in sharedprefrence you can use the below code.
SharedPreferences myprefs = getApplicationContext();
                     boolean username_set = myprefs.contains("userid ");
                     if (username_set ) {
                           return true;
                     } else {
                           return false;
                     }

It will check the userid is present in the sharedprefrence if its not it will return as false
LogOut:
In Logout button, when the user click logout you need to clear the stored details in Sharedprefrence,then move to login page .
In such case you just use the below code, when doing Logout Process.
SharedPreferences myprefs = c.getSharedPreferences("user",
                           Context.MODE_PRIVATE);
              SharedPreferences.Editor editor = myprefs.edit();
              editor.remove("userid");

Then move the user to login Activity or complete exit the user by using below code..
Intent i =new Intent(Intent.ACTION_MAIN);
              i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
              i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
              i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              i.addCategory(Intent.CATEGORY_HOME);
c.startActivity(i);

Thas’it I mostly I cover all the details that have been used in Login process should follow in android
application.
If you have any doubts regarding the process just post your comments below..
Happy Coding……..


HI. I got this above error , when I try to convert string to date type format.
In my scenario   I get  the data in string variable then I need to convert the string to certain Date format.
For that I tried many ways to accomplish my needs but each try I got this below error..

java.text.ParseException: Unparseable date: "01-08-2012"

Finally my friend refer the code ,then I convert the string to my date format.
Requirement Format I need:
“02 Feb “I need to this type of Format
Before the start the process you need to import the below namespace….

import java.util.*;
import java.text.*;

This the code finally Work For me…………..
String strformat="MMM-dd";
String ddate="01-08-2012";//Date in string format
try{
                     SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
                     java.util.Date date=sdf.parse(ddate);
                     sdf=new SimpleDateFormat("dd-MMM");//Format i need
                          
                     Toast.makeText(this, sdf.format(date), Toast.LENGTH_LONG).show();
                           }
              catch(Exception ex){
                     Toast.makeText(this, ex.toString(), Toast.LENGTH_LONG).show();
              }
Result:
01-Aug

Any Doubts please share with comments..
Happy Coding……….


When using spinner in android we set the data to spinner using adapter.

Normally we get the data in array string and we store the value in spinner using adapter.
In some situation we need select the data through dynamic at the time we need to follow the below process to set the data in Spinner.
But spinner has to allow set the data only by positions. But we need to choose by data like dropdown list.
In that situation we have to follow the below process….

String[] name;
name =new String[]{"name1","name2","name3","name4","name5"};
ArrayAdapter adapter = new ArrayAdapter(this,
                                                                                android.R.layout.simple_spinner_item, name);
spinccy.setAdapter(adapter);

IF we want to set spinner selected data as “name3”
First we find the position of the data in adapter
int Position = adapter.getPosition(“name3”);
spinccy.setSelection(Position);

Thast’it this process you need to follow to set the data by value in spinner.
Happy Coding………….