Thanx sir, Code is :
@SuppressWarnings("deprecation") public class xyzextends Activity implements OnClickListener { /** Called when the activity is first created. */ public static int Count=15; private Timer myTimer; String CellNo[]=new String[10]; String CellToDial; private SQLiteDatabase db=null; static int PhoneNocount=5; Intent dial =null; private Location currentLocation; private double currentLatitude=0; private double currentLongitude=0; LocationManager locationManager; int Address_Effort_count =5; TextView txtAddress; int FlagGetAddress=0; StringBuilder result =null; LocationListener locationlistener; TextView txtstatus; TextView txtSMSstatus; TextView txtEmailstatus; String add=""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ////////////////////////////////////////////////////////////////////////////////////////////// Button btnMovetoConfig =(Button) findViewById(R.id.buttonok); btnMovetoConfig.setOnClickListener(this); result = new StringBuilder(); result.append(""); appendLog("\n </br>\n </br>Timer Start\n </br>"); txtstatus = (TextView) findViewById(R.id.status); txtSMSstatus =(TextView) findViewById(R.id.SMSstatus); txtEmailstatus =(TextView) findViewById(R.id.EMAILstatus); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// db =(new DbBasic(this)).getWritableDatabase(); try { db.execSQL("CREATE TABLE IF NOT EXISTS ContactList ();"); } catch(Exception e) { Log.v("Table Already Exsists",e.toString()); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// try { appendLog("\n </br>Find_Current_LatLong() Called : 1\n </br>"); Find_Current_LatLong(); } catch(Exception e) { Toast.makeText(this,"Please Restart Application,Can't Find Lat Long!!", Toast.LENGTH_SHORT).show(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(constantsCursor.getCount()>0) { appendLog("\n </br>There is a Row in ContactList\n </br>Value Is :"); int i=1; for(constantsCursor.moveToFirst();!constantsCursor.isAfterLast();constantsCursor.moveToNext()) { appendLog(constantsCursor.getString(1)+"\n </br>"); CellNo[i] = constantsCursor.getString(1); i++; } } else { txtstatus.setText("fill Configuration Details!!"); Toast.makeText(this,"Necessory Informations Required.\n </br>Please Fill The Configuration Details.", Toast.LENGTH_LONG).show(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } catch(Exception e) { Toast.makeText(this,"Please Restart Application,Error In Db access:" + e.toString(), Toast.LENGTH_SHORT).show(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { TimerMethod(); } }, 0, 1000); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } private void TimerMethod() { //This method is called directly by the timer //and runs in the same thread as the timer. //We call the method that will work with the UI //through the runOnUiThread method. this.runOnUiThread(Timer_Tick); } private Runnable Timer_Tick = new Runnable() { public void run() { //This method runs in the same thread as the UI. //Do something to the UI thread here Button OkBtn =(Button)findViewById(R.id.buttonok); Count--; String CntStr; CntStr = Integer.toString(Count); OkBtn.setText(CntStr); txtAddress =(TextView)findViewById(R.id.txtAddress); appendLog("\n </br>Timer Count is"+ CntStr +"\n </br>"); /*//Find Address if(currentLatitude != 0 && currentLongitude != 0) { txtstatus.setText("Wait....Locating Accident Place!"); getAddress(); }*/ if(Count <=0) { appendLog("\n </br>Timer Tick Count Is 0\n </br>"); myTimer.cancel(); try { while(Address_Effort_count>0) { appendLog("\n </br>Address_Effort_count is :"+Address_Effort_count +"\n </br>"); Address_Effort_count--; if(currentLatitude == 0 && currentLongitude == 0) { Find_Current_LatLong(); } } } catch(Exception e) { txtAddress.setText(e.toString()); appendLog("\n </br>Message Sending Status:"+e.toString()); } } } }; private void Find_Current_LatLong() { try { appendLog("\n </br>Find_Current_LatLong(); Called \n </br>"); txtstatus.setText("Wait....Locating Accident Place!"); //Find Latitude & Longitude locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); locationlistener = new LocationListener() { public void onLocationChanged(Location location) { locationManager.removeUpdates(locationlistener); updateLocation(location); } public void onStatusChanged( String provider, int status, Bundle extras) { switch (status) { case LocationProvider.AVAILABLE: txtstatus.setText("GPS available again\n"); break; case LocationProvider.OUT_OF_SERVICE: txtstatus.setText("GPS out of service\n"); break; case LocationProvider.TEMPORARILY_UNAVAILABLE: txtstatus.setText("GPS temporarily unavailable\n"); break; } } public void onProviderEnabled(String provider) { txtstatus.setText("GPS Enabled"); } public void onProviderDisabled(String provider) { txtstatus.setText("GPS Disabled"); } }; locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 50, locationlistener); } catch(Exception e) { Toast.makeText(this,"Find_Current_LatLong: "+e.toString(), Toast.LENGTH_LONG).show(); appendLog("\n </br>Error in Find_Current_LatLong" +e.toString() ); } } void updateLocation(Location location){ try { appendLog("\n </br>update Location called \n </br>"); currentLocation = location; currentLatitude = currentLocation.getLatitude(); currentLongitude = currentLocation.getLongitude(); appendLog("\n </br>Lat long is: \n </br>"+ Double.toString(currentLatitude) +" "+ Double.toString(currentLongitude)); txtstatus.setText("Latitude & Longitude Found!"); getAddress(); if(location!=null) { locationManager.removeUpdates(locationlistener); appendLog("\n </br>Location Updater Removed \n </br>"); } } catch(Exception e) { Toast.makeText(this,"Location Update Not Succeed!"+e.toString(), Toast.LENGTH_LONG).show(); } } protected void getAddress() { try{ appendLog("\n </br>Get Address Called \n </br>"); txtstatus.setText("Converting GeoCordinate To Address !"); appendLog("\n </br>GetAddress start finding Address \n </br>"); /* Toast.makeText(this,"Enter in getAddress null string cond", Toast.LENGTH_LONG).show(); Geocoder gcd = new Geocoder(this, Locale.getDefault()); List<Address> addresses = gcd.getFromLocation(currentLatitude, currentLongitude,100); if (addresses.size() > 0) { result = new StringBuilder(); for(int i = 0; i < addresses.size(); i++){ Address address = addresses.get(i); int maxIndex = address.getMaxAddressLineIndex(); for (int x = 0; x <= maxIndex; x++ ){ result.append(address.getAddressLine(x)); result.append(","); } result.append(address.getLocality()); result.append(","); result.append(address.getPostalCode()); result.append("\n </br>\n </br>"); } appendLog("\n </br>Address Found:"+ result.toString() + "\n </br>"); txtstatus.setText("Address Found!"); } try { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> addresses1 = geocoder.getFromLocation(currentLatitude, currentLongitude,1); Address obj = addresses1.get(0); add = obj.getAddressLine(0); add = add + "\n </br>" + obj.getCountryName(); add = add + "\n </br>" + obj.getCountryCode(); add = add + "\n </br>" + obj.getAdminArea(); add = add + "\n </br>" + obj.getPostalCode(); add = add + "\n </br>" + obj.getSubAdminArea(); add = add + "\n </br>" + obj.getLocality(); add = add + "\n </br>" + obj.getSubThoroughfare(); appendLog("\n </br>Address Found:"+ add + "\n </br>"); txtstatus.setText("Address Found!"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); } } if(Count<=0) { appendLog("\n </br>Count Set to 15 \n </br>"); Count=15; appendLog("\n </br>Finishing Activity\n </br>"); finish(); } } catch(Exception ex){ Toast.makeText(this,"getAddress :"+ex.toString(), Toast.LENGTH_LONG).show(); } } } Problem is : 1. UpdateRemove doesn't work. 2. I need to do following thing : -> Get Address Once (By calling getaddress()), -> After Getting Address,UpdataLocation function should not call. -- >so, Address will set Once Timer should stop Application Finish() / Close . On 1/13/12, Spiral123 <cumis...@gmail.com> wrote: > 1. Appreciate that English is probably not your first language, but > plz dnt mk it evn hrdr fr ppl to read you posts by contracting words. > > 2. Good that you have the whole code already. If you are having a > problem with it can you post a section of the LogCat where it falls > over or a (small) snippet of the source that shows where you are > having a problem? Then you will have a better chance of a positive > response. > > thanks > > > On Jan 13, 6:10 am, Dhaval Varia <dhavalkva...@gmail.com> wrote: >> jst....mind ur buisness... >> i m having whole code...trying since last 3days.then asked qustion.. >> >> i m sending email having that address...dt time my app got stuck...not >> responding. >> >> i m jst trying to know,whats wrong in my code.. >> >> dnt blame any one.without knowing everything.... >> >> sorry for hard words... >> On Jan 13, 2012 1:49 PM, "Ali Chousein" <ali.chous...@gmail.com> wrote: >> >> >> >> >> >> >> >> > You are basically looking for someone who is going to do all the job >> > for you and you'll have all the credit. Try registering to any >> > "product-managers" group or change your profession. >> >> > On Jan 13, 4:25 am, Dhaval Varia <dhavalkva...@gmail.com> wrote: >> > > i am writing one app. >> > > in which >> > > 1. gps find lat long by calling update location >> > > 2. using this find address. this function calles in updatelocation >> >> > > my que is: >> >> > > update location called periodically. >> >> > > it will call fun for getting address,inturn. >> >> > > i dont want to call fun of getting address periodically. >> >> > > it should call only once,after getting lat long. >> >> > > plz help. >> >> > > Plz let me know how to start progressbar,start before calling >> > > updatelocation and stop after getting addreas. >> >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Android Developers" group. >> > To post to this group, send email to android-developers@googlegroups.com >> > To unsubscribe from this group, send email to >> > android-developers+unsubscr...@googlegroups.com >> > For more options, visit this group at >> >http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Thanks & Best Regards. ---------------------------------------------------------------------------------------- Dhaval varia Assistant Professor Govt Engineering College,Modasa (9924343883) -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en