Tuesday, August 18, 2015

Alert Dialog in Android

show alert dialog in Android for validation or other purpose, show alert dialog with message and when click on Ok then Dismiss.

it pop up on screen and display message.

Context context;
String message;
AlertDialog alert = null;

AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(message)
      .setCancelable(false)
      .setPositiveButton("OK", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
          alert.dismiss();
          }
      });
alert = builder.create();
alert.show();
}

Wednesday, August 12, 2015

Show Image Using Picasso in Android

Picasso is powerful Image Loading Library in Android, it caching image and manage memory automatically and large image easily handle in Android.


Working with Images In Android:

In Android handle many Image and manage them is complex, some time "Out Of Memory Error Occur" due to large size Images and we need to recycle and free memory after image load.


Monday, August 10, 2015

Get Gmail Address Of User In Android Programatically

In Android get user gmail address programatically in android using AccountManager.

    try {
AccountManager accountManager = AccountManager.get(context);
Account[] accountsEmail = accountManager.getAccountsByType("com.google");
Account email = accountsEmail[0];
return email.name;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Friday, August 7, 2015

Search in Listview Android

Search inside listview using addTextChangedListener , in listview when EditText we search then below list show related search  list data. 

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.