Posts

Showing posts from February, 2013

How to set Button Enable and Disable using Android

Add button to layout, then add the following code java file.        Button btnCalcualte=(Button) findViewById(R.id.button1);               // to enable button                           btnCalcualte.setEnabled(true);                 // to disable button                       btnCalcualte.setEnabled(false);      

Alert Dialog When User Press Back Button

Override  the following method  of Activity to add Key event into Android Application. @Override public boolean onKeyDown ( int keyCode , KeyEvent event ) { if (( keyCode == KeyEvent . KEYCODE_BACK )) { AlertDialog . Builder alertbox = new AlertDialog . Builder ( HomeActivity . this ); alertbox . setIcon ( R . drawable . info_icon ); alertbox . setTitle ( "You Want To Exit Programm" ); alertbox . setPositiveButton ( "Yes" , new DialogInterface . OnClickListener () { public void onClick ( DialogInterface arg0 , int arg1 ) {     // finish used for destroyed activity finish (); } }); alertbox . setNegativeButton ( "No" , new DialogInterface . OnClickListener () { public void onClick ( DialogInterface arg0 , int arg1 ) { // Nothing will be happened when clicked on no button   

SmS Reading in Android Programmatically

Image
An Android you can read Sms programmatically. When you able to read Sms Programmatically then you can do more advance task by this operation. Like I read sms and Change profile of the phone and read contact by name and the result of contact search are send back to my phone from where we search the contact. Let Enjoy it. Create new project and  add class SmsRemoteController and extends it from BroadcastReceiver . BroadcastReceiver class is a single method onReceive() .Add the following code in onReceive() method. String sendingNumber=""; String smsBody=""; Bundle bundle=intent.getExtras();             SmsMessage[] msgs = null;             String smsBody="";               if (bundle!=null) {                     Object[] pdus=(Object[])bundle.get("pdus");                     msgs=new SmsMessage[pdus.length];                     for (int i = 0; i < pdus.length; i++) {                           msgs[i] = SmsMessage.createFromPd

Android Age Calculator

Image
In this application we calculate total year, months and day of our age. You simply enter Data of Birth to calculate it. Let start the fun First we Create AgeCalcualtion class where we add all calculation method to calculate Year, Months and Day from date of Birth public class AgeCalculation { private int startYear; private int startMonth; private int startDay; private int endYear; private int endMonth; private int endDay; private int resYear; private int resMonth; private int resDay; public String getCurrentDate() { Calendar c=Calendar.getInstance(); endYear=c.get(Calendar.YEAR); endMonth=c.get(Calendar.MONTH); endMonth++; endDay=c.get(Calendar.DAY_OF_MONTH); return endDay+":"+endMonth+":"+endYear; } public void setDateOfBirth(int sYear, int sMonth, int sDay) { startYear=sYear; startMonth=sMonth; startMonth++; startDay=sDay; } public void calcualteYear() { resYear=endYear-startYear; } public void calcualteMonth() { if(endMont