web stats analysis

Android Archive

How to add android date time picker?

Android Date Time Picker Dialog.

Add the following namespace.

->Android additionally supports widgets such as DatePicker, TimePicker as well as dialogs just like DatePickerDialog, TimePickerDialog for helping users enter dates and times.
->The DatePicker and also DatePickerDialog are same it’s enable you to set the starting date for selection, in the form of a year, month, and day of month value.
->Both are give a callback object OnDateChangedListener or even OnDateSetListener where you are informed of a new date selected from the user.
->You are able to store that date somewhere because there is no some other way for you to get at the chosen date later on.
->To Test this Date and Time Picker widget, create an android project and place two buttons.One for set the date and another one for set the time. And display the end result in a textview.

Demo example of Date Time picker is like below:

Creating Layout for Date Time Picker Widget

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" >
        android:text="@string/time_text" />

Java code to configure the Date Time Picker Widget:


package com.vimaltuts.android.androiddatetimepicker;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import java.text.DateFormat;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
public class AndroidDateTimePickerActivity extends Activity {
private Button timeBtn;
private Button dateBtn;
DateFormat formatDateTime=DateFormat.getDateTimeInstance();
Calendar dateTime=Calendar.getInstance();
private TextView timeLabel;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
public void chooseDate(){
new DatePickerDialog(AndroidDateTimePickerActivity.this, d, dateTime.get(Calendar.YEAR),dateTime.get(Calendar.MONTH), dateTime.get(Calendar.DAY_OF_MONTH)).show();
public void chooseTime(){
new TimePickerDialog(AndroidDateTimePickerActivity.this, t, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE), true).show();
DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) {
dateTime.set(Calendar.MONTH, monthOfYear);
dateTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
private void updateLabel() {
->In the button property we allocated a related method to each button that should be called when the user clicks it.
->For the DatePickerDialog, we give it a OnDateSetListener callback that updates the Calendar with the new date.
->For the TimePickerDialog, it gets a OnTimeSetListener callback to update the time part of the Calendar.

For more detail Click here..

How to set text of TextView in android?

I had to solved the problem of How to set text of TextView..

The solution is below…


private TextView demoTextView;

private String demoString;

demoTextView = (TextView) findViewById(R.id.tv);

demoString = “hello friends ! wht’s up?”;


How to resume an App from a Notification?

Note:In this solution you have to set your flags… 

notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;

notification.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

How to handle multiple notification in android?

Many time we would send multiple notification to users in a short time,
and you can handle “more than one” unread notification at a time in your Android application.

Here I explian you the simple tips to handle multiple notifications in your Android application.

I solved this problem in Android version 3.0.

The demo code when generate notification :

NotificationManager demonotification = (NotificationManager)


Notification notification = new Notification(icon, message, when);

String title = context.getString(R.string.app_name);//The notification title

Date now = new Date();

long uniqueId = now.getTime();

Note:-Fill the information whatever you pass in your notification to the intent.
Change the HomeActivity and class name what you wish to start when user click on the notificaiton..

Intent notificationIntent = new Intent(context, HomeActivity.class);

notificationIntent.putExtra(“IS_NOTIFICATION”, true);
notificationIntent.putExtra(“NOTIFICATION_MSG”, message);

Note:-if u dosen’t need to strat new activity must set Intent.

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |

Note:-if you want to represent your notification so you cought use unique string.
But remember that tha each and every notification have difference action name..

notificationIntent.setAction(“com.sample.myapp” + uniqueId);

PendingIntent intent =PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;

Note:- How to Play default notification sound?
notification.defaults |= Notification.DEFAULT_SOUND;
notification.sound = Uri.parse(“android.resource://” + context.getPackageName() +
Note:- When vibrate is enabled.and you want a vibrate
notification.defaults |= Notification.DEFAULT_VIBRATE;
Note:-If you use the same uniqueId for each notification, the Notification Manager will assume that is same notification and would replace the previous notification. **/
notificationManager.notify((int) uniqueId, notification);
I hope you are easily understand this code and enjoy android development.
Thank you…

The connection to adb is down and a severe error has occurred.

Follow below steps
Step 1 :- Open your task manager.
Step 2 :- Now go to processes tab.
Step 3 :- Now find adb.exe and select it.
Step 4 :- Now click on End Process button.
Step 5 :- Now restart your eclipse and run your application.

How to Configure Android SDK with Eclipse IDE to develop Application

It is easy to configure android SDK to develop application.

To configure android SDK with Eclipse IDE to develop android application follow the below steps:

1.Download Android SDK From Here.

2.Now, Extract the android-sdk_r18-windows.zip.

Read the rest of this entry »