Friday, August 7, 2015

Hide Keyboard in Android

Hide keyboard in android on button click or layout click some time we notice that after enter data in edittext when click button then still show keyboard on eittext, we need to hide keyboard on button click.

some time we switch one activity to another activity then if keyboard open in first activity then it also show in second activity.

hide soft keyboard in android
Hide keyboard android

Thursday, August 6, 2015

Data store and retrieve in android using sqlite database

Store Data in SQLite Database Android:

many ways to storage data in android like Share Preference and other but store data using SQLite is parmanent and can be in many format. In Share Preference save data in key-value pair.

For SQLite we extend SQLiteOpenHelper and @Override write query and save data.

Add Data in Android Using SQLite Database
Add Data in Android Using SQLite Database 

Thursday, June 18, 2015

Passing Data Between Activities in Android

passing data from one activity to another activity in android using intent.

Suppose two Activity : FirstActivity and SecondActivity. if we want to send data from FirstActivity  to SecondActivity  then we move from another activity using Intent 

We Send data in key-value form.

Convert timestamp to date and time in android

Here Timestamp means UNIX timestamp,convert to date and time in android. suppose timestamp is 1434624342http://www.currenttimestamp.com/) and show into DD-MM-YYYY and HH:MM  format.

           long time=1434624342;
           Calendar cal = Calendar.getInstance(Locale.ENGLISH);
    cal.setTimeInMillis(time);
    String date = DateFormat.format("dd-MM-yyyy hh:mma", cal).toString();

Sunday, February 22, 2015

Load URL in WebView Android

Open URL in WebView:

In android open website by using WebView. WebView use for display website content in android like as browser.

What is WebView:

WebView use for open website in android like browser. WebView display all website data in andriod.
Like this URL open in WebView http://invokecode.blogspot.in/

WebView in Android
WebView in Android

Tuesday, February 17, 2015

Create Custom ListView in Androd

What is Custom ListView:

custom list view means custom Layouts and show custom Item in listview. in simple listview use only text or image show in list using ArrayAdapter but in custom listview we use CustomAdapter.
custom listview may be many image or text.

Create Custom ListView in Android
Custom ListView in Android

Why Use Custom Listview: 

as we discuss simple listview contain only simple layout so we need custom layout for custom listview. custom listview contain images and text and many more.

Friday, January 9, 2015

AsyncTask in Android

AsyncTask in Android:

AsyncTask in Android
AsyncTask in Android


Asynctask  in android use for network operation like upload data  and get data from server means "Network Related Task" If without use of AsyncTask we do network related task then "RunOnUIException "  error Occur.

Create AsyncTask  by extend Async , Params,Progress and Result  can be chnage according to need, likes if need String Type data then change String.

AsyncTask method  onPreExecutedoInBackgroundonProgressUpdate and onPostExecute and for acess UI mean without network related task like set value in textbox or show progress dialog etc. onPreExecute and onPostExecute Only for UI. and for "Network Related Task" use doInBackground. method.

for short operation we use AsyncTask and if need large data then use  ExecutorThreadPoolExecutor and FutureTask. easy manage UI and Background related work in AsyncTask but In case of Thread for UI we need runOnUiThread method or handler.

 Create AsyncTask:

                              class AstncTask extends AsyncTask {
                                      @Override
protected void onPreExecute() {
// TODO Auto-generated method stub
                                           super.onPreExecute();
                                          // For UI  
 }

                                           @Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
                                               //"Network Related Task"
}

                                            @Override
                                              protected void onPostExecute(String result) { 
                                               super.onPostExecute(result);
                                               //after doInBackground it call 
                                                 // UI   related work
                                              }
}

Call AsyncTask

new AsyncTask().execute();

visithttp://invokecode.com/  for More Tutorials 

if any query related this tutorial  then please comments !!

Thank You !!

Saturday, January 3, 2015

Progress Dialog in Android

show progress dialog in android:

ProgressDialog pDialog; //initialize
pDialog = new ProgressDialog(context); //  pass context or activity.this
pDialog.setMessage(“Please wait…”);// set Message
pDialog.show(); // showing
pDialog.dismiss(); // dismiss

Email Validation in Android:

Email Validation in Android:


Email validation in android, simply we match Pattern like name@gmail.com  format…
String.matches  if match then email format is valid else not valid format..
for email Pattern:
String pattern= “[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+”;
if (ourEmail.matches(pattern)) {
Email valid format
}
else{
“invalid email  format!!
}

Custom Dialog in Android

Show custom dialog in android:

Custom Dialog in Android
Dialog dialog=new Dialog(MainActivity.this);
// inflate layout here
dialog.setContentView(R.layout.custon_dialog_layouts);
dialog.setTitle(“Custom Dialog”);
// define custom dialog button , edittext etc. here and their click
like example
Button button=(Button) dialog.findViewById(R.id.cancelDialog);
// Button = dialog nanem.related find id//
// dialog.dismiss for dismiss dialog
dialog.show();
Note:if any issue to implement then comment.
Thank You !!