[android-developers] Re: Service not available
Did u checked the code...i think there can be problem in the code also for reverse geocoding...please check... On Feb 21, 7:53 pm, Mychandus Msb wrote: > I got this error many times, this is not because of the code, this is > because of device not able to get proper satellite signals. if you can get > the device into open sky you may get the required inforamtion. > > > > > > > > > > On Tue, Feb 21, 2012 at 7:57 PM, ajay talreja wrote: > > I want to retrieve the address of the location when i am passing the > > longitude and latitude from Command line through Telnet...The > > application do get latitude and longitude updates when i change from > > command line.. > > im providing with the code...the code doesn't have any > > error.but is unable to show the address of the > > locationit shows "LocationProvider.TEMPORARILY_UNAVAILABLE > > "If the service is not available how is it taking the values > > from command line..? > > i donno where i have gone wrong... :-( > > please help.. > > > import java.io.IOException; > > import java.text.SimpleDateFormat; > > import java.util.Date; > > import java.util.List; > > import java.util.Locale; > > > import android.app.Activity; > > import android.app.AlertDialog; > > import android.content.DialogInterface; > > import android.location.Address; > > import android.location.Geocoder; > > import android.location.Location; > > import android.location.LocationListener; > > import android.location.LocationManager; > > import android.location.LocationProvider; > > import android.os.Bundle; > > import android.widget.TextView; > > import android.widget.Toast; > > > public class GPSTest extends Activity implements LocationListener { > > > private TextView mInfoText; > > private LocationManager mLoc; > > > private static final Integer MINIMUM_UPDATE_INTERVAL = 1; // > > update every 10 seconds > > private static final Integer MINIMUM_UPDATE_DISTANCE = 10; // > > update every 10 meters > > > /** Called when the activity is first created. */ > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > > // get a handle to the text view to display the GPS location > > data > > mInfoText = (TextView) findViewById(R.id.infotext); > > > // the location manager allows access to the current location > > and GPS status > > mLoc = (LocationManager) getSystemService(LOCATION_SERVICE); > > } > > > @Override > > /** > > * onResume is is always called after onStart, even if the app > > hasn't been paused > > */ > > protected void onResume() { > > // add a location listener and request updates every 1ms or > > 10m > > mLoc.requestLocationUpdates(LocationManager.GPS_PROVIDER, > > MINIMUM_UPDATE_INTERVAL, > > MINIMUM_UPDATE_DISTANCE, this); > > super.onResume(); > > } > > > @Override > > protected void onPause() { > > // GPS, as it turns out, consumes battery like crazy > > mLoc.removeUpdates(this); > > super.onPause(); > > } > > > @Override > > protected void onStop() { > > // may as well just finish since saving the state is not > > important for this toy app > > finish(); > > super.onStop(); > > } > > > public void onLocationChanged(Location loc) { > > // display some information based on the current position > > StringBuilder sb = new StringBuilder("Your current location is:\n > > \n"); > > > sb.append("Longitude: "); > > sb.append(loc.getLongitude()); > > sb.append('\n'); > > > sb.append("Latitude: "); > > sb.append(loc.getLatitude()); > > sb.append('\n'); > > > sb.append("Altitiude: "); > > sb.append(loc.getAltitude()); > > sb.append('\n'); > > > sb.append("Accuracy: "); > > sb.append(loc.getAccuracy()); > > sb.append('\n'); > > > sb.append("Timestamp: "); > > Date timestamp = new Date(loc.getTime()); > > sb.append(new SimpleDateFormat().format(timestamp)); > > > try{ > > Geocoder gcd = new Geocoder(this, Loca
[android-developers] Service not available
I want to retrieve the address of the location when i am passing the longitude and latitude from Command line through Telnet...The application do get latitude and longitude updates when i change from command line.. im providing with the code...the code doesn't have any error.but is unable to show the address of the locationit shows "LocationProvider.TEMPORARILY_UNAVAILABLE "If the service is not available how is it taking the values from command line..? i donno where i have gone wrong... :-( please help.. import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Locale; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; public class GPSTest extends Activity implements LocationListener { private TextView mInfoText; private LocationManager mLoc; private static final Integer MINIMUM_UPDATE_INTERVAL = 1; // update every 10 seconds private static final Integer MINIMUM_UPDATE_DISTANCE = 10;// update every 10 meters /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // get a handle to the text view to display the GPS location data mInfoText = (TextView) findViewById(R.id.infotext); // the location manager allows access to the current location and GPS status mLoc = (LocationManager) getSystemService(LOCATION_SERVICE); } @Override /** * onResume is is always called after onStart, even if the app hasn't been paused */ protected void onResume() { // add a location listener and request updates every 1ms or 10m mLoc.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_UPDATE_INTERVAL, MINIMUM_UPDATE_DISTANCE, this); super.onResume(); } @Override protected void onPause() { // GPS, as it turns out, consumes battery like crazy mLoc.removeUpdates(this); super.onPause(); } @Override protected void onStop() { // may as well just finish since saving the state is not important for this toy app finish(); super.onStop(); } public void onLocationChanged(Location loc) { // display some information based on the current position StringBuilder sb = new StringBuilder("Your current location is:\n \n"); sb.append("Longitude: "); sb.append(loc.getLongitude()); sb.append('\n'); sb.append("Latitude: "); sb.append(loc.getLatitude()); sb.append('\n'); sb.append("Altitiude: "); sb.append(loc.getAltitude()); sb.append('\n'); sb.append("Accuracy: "); sb.append(loc.getAccuracy()); sb.append('\n'); sb.append("Timestamp: "); Date timestamp = new Date(loc.getTime()); sb.append(new SimpleDateFormat().format(timestamp)); try{ Geocoder gcd = new Geocoder(this, Locale.getDefault()); List addresses = gcd.getFromLocation(loc.getLatitude(), loc.getLongitude(),100); if (addresses.size() > 0) { StringBuilder 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\n"); } sb.append(result.toString()); } } catch(IOException ex){ sb.append(ex.getMessage().toString()); } mInfoText.setText(sb.toString()); } public void onProviderDisabled(String provider) { // called if/when the GPS is disabled in settings Toast.makeText(this, "GPS disabled", Toast.LENGTH_LONG).show(); // end program since we depend on GPS AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertbox.setMessage("This demo app requires GPS. Please activate it first!"); alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { finish(); } }); alertbox.show(); } public void on
[android-developers] Re: Shared Preferences
thanks Poncho, but i had given suffix 'L' any how .puttin a single st "e.printstack.." in catch block ...it worked.i donno logic behind that...but it did. thanks alot... On Feb 8, 12:31 am, poncho wrote: > Hi, > > The code itself is fine except that you don't print the exception. > > If you would log the exception you can see (in the LogCat) that the > run-time is throwing some kind of a ParseException. > This is since users (usually) don't type 'L' at the end of their numeric > input, even when it's long. > > Hope this helps > /Poncho > > On 02/07/2012 02:54 PM, ajay talreja wrote: > > > > > > > > > This code is not working for mei'm trying to use Shared > > preferences to store long values.the code is correct and is > > launching successfully when i switch from long to int valuesplease > > help > > > package d.preferencesdemo1; > > > import android.app.Activity; > > import android.content.SharedPreferences; > > import android.os.Bundle; > > import android.preference.PreferenceManager; > > import android.view.View; > > import android.widget.Button; > > import android.widget.EditText; > > import android.widget.TextView; > > > public class preferencesdemo1 extends Activity { > > /** Called when the activity is first created. */ > > EditText t; > > long mobileno; > > TextView text; > > SharedPreferences app_preferences; > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > // Get the app's shared preferences > > app_preferences = > > PreferenceManager.getDefaultSharedPreferences(this); > > > mobileno = app_preferences.getLong("mobileno",9028252169L); > > > // Update the TextView > > text = (TextView) findViewById(R.id.text); > > text.setText("The default mobile number is " + mobileno + > > "."); > > > // Increment the mobileno > > // SharedPreferences.Editor editor = app_preferences.edit(); > > // editor.putlong("mobileno", ++mobileno); > > //editor.commit(); // Very important > > > t = (EditText) findViewById(R.id.EditText01); > > > Button b2 = (Button) findViewById(R.id.Button01); > > t.setText(""); > > > b2.setOnClickListener(new View.OnClickListener() { > > public void onClick(View view) { > > > try { > > // Increment the mobileno > > SharedPreferences.Editor editor = > > app_preferences.edit(); > > long tv = > > Long.parseLong(t.getText().toString()); > > mobileno=tv; > > editor.putLong("mobileno", mobileno); > > editor.commit(); // Very important > > > text.setText("The default mobile number is " > > + mobileno + "."); > > > } > > catch (Exception e) { > > > } > > } > > }); > > > } > > } -- 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
[android-developers] Shared Preferences
This code is not working for mei'm trying to use Shared preferences to store long values.the code is correct and is launching successfully when i switch from long to int valuesplease help package d.preferencesdemo1; import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class preferencesdemo1 extends Activity { /** Called when the activity is first created. */ EditText t; long mobileno; TextView text; SharedPreferences app_preferences; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get the app's shared preferences app_preferences = PreferenceManager.getDefaultSharedPreferences(this); mobileno = app_preferences.getLong("mobileno",9028252169L); // Update the TextView text = (TextView) findViewById(R.id.text); text.setText("The default mobile number is " + mobileno + "."); // Increment the mobileno // SharedPreferences.Editor editor = app_preferences.edit(); // editor.putlong("mobileno", ++mobileno); //editor.commit(); // Very important t = (EditText) findViewById(R.id.EditText01); Button b2 = (Button) findViewById(R.id.Button01); t.setText(""); b2.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { try { // Increment the mobileno SharedPreferences.Editor editor = app_preferences.edit(); long tv = Long.parseLong(t.getText().toString()); mobileno=tv; editor.putLong("mobileno", mobileno); editor.commit(); // Very important text.setText("The default mobile number is " + mobileno + "."); } catch (Exception e) { } } }); } } -- 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
[android-developers] Re: android help
have tried as you told to change "Try getting the location through a location update. (Use requestLocationUpdate() or requestSingleUpdate() instead.)" but it is also not working for meproviding the code for your review.. Code: "gps12.java " package d.gps12; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.TextView; public class gps12 extends Activity { /** Called when the activity is first created. */ TextView t1,t2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener ll = new mylocationlistener(); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll); t1=(TextView) findViewById(R.id.TextView01); t2=(TextView) findViewById(R.id.TextView02); t1.setText("hii"); t2.setText("h"); } private class mylocationlistener implements LocationListener { public void onLocationChanged(Location location) { if (location != null) { t1.setText((int) location.getLatitude()); t2.setText((int) location.getLongitude()); } else { t1.setText("unable"); t2.setText("unable"); } } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } } } After launching this application, I'm passing latitude and long. values from emulator and have also tried passing from command line through telnet ..but location values seems to be empty so...the latitude and long. values are not getting displayed. and the "text view" are not changing the values.it means that "location changed " method is not getting execute neither its "if" part nor its "else" part..so what might be the problem isn't the code correct or what might be the other problems..??? please get it run on your system help please.. thanks -- 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
[android-developers] Re: android help
@kris : Sorry. I'll start again. I have problem with my GPS location applicationmy application is not able to retrieve latitude and longitude... I'm providing the code for your reference.the below application is launching successfully on emulator but unable to retrieve the values into Text View.I have tried passing values from Emulator Control and through command line via TELNETthen with Geo-pointsplease go through the code..and tell me where i have gone wrong... Files are as follows 1) gps.java package d.gps; import android.app.Activity; import android.os.Bundle; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.widget.TextView; public class gps extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager locationManager; locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); updateWithNewLocation(location); } /** Update UI with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView)findViewById(R.id.myLocationText); String latLongString; if (location != null) { double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; } else { latLongString = "No location found"; } myLocationText.setText("Your Current Position is:\n" + latLongString); } } 2) main.xml http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > 3)String.xml Hello World, gps! gps 4) androidmanifest.xml http://schemas.android.com/apk/res/android"; package="d.gps" android:versionCode="1" android:versionName="1.0"> thanks. -- 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
[android-developers] Re: android help
@treking : thanks...but have tried them as well @kris : thanks. @kris : You mean by forcing a geo fix with mock locations or using a "fake gps" type application? No, I'm not trying to modify the locationsI'm just passing the values from emulator control which are default present in EditText of Emulator controland also tried to pass from command line...by Telnet methodbut both are not working for me...i donno why???.Sir ,did u referred to my code in above post.there may be a possibility of having a bug in my code...please check...then lemme know On Jan 29, 1:09 am, Kristopher Micinski wrote: > On Sat, Jan 28, 2012 at 1:43 PM, ajay talreja wrote: > > okkk. > > For my first application...Emergency Sms which send msg at one tab of > > application or key,as you said long pressed on application is not > > possible.so is there any method to do code on numeric > > keypadlike speed diali want to send message from my numeric > > keylike when one is pressed.A message should be sent to > > specified number..if yes provide me with that help > > also > > No. Not unless you modify the firmware. > > > > > For my second application ,i'll need Gps values so > > I'm just trying to retrieve values of latitude and longitude values > > from my basic applicationand display them to Text view.in > > above post of mine i have provided with the code of the > > samethere are no errors.it do get launch on > > emulator...but application is not retrieving the values of > > longitude and latitudeso... is there any kinda mistake in > > my code???...or what are the other reason of not getting > > latitude and longitude ..i have tried providing values from > > Emulator and command line..but it is not able to retain the values > > of latitude and longitude... > > You mean by forcing a geo fix with mock locations or using a "fake > gps" type application? > > FYI, any time you're wondering if you can modify the platform beyond > your app the answer is usually no. > > kris -- 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
[android-developers] Re: android help
okkk. For my first application...Emergency Sms which send msg at one tab of application or key,as you said long pressed on application is not possible.so is there any method to do code on numeric keypadlike speed diali want to send message from my numeric keylike when one is pressed.A message should be sent to specified number..if yes provide me with that help also For my second application ,i'll need Gps values so I'm just trying to retrieve values of latitude and longitude values from my basic applicationand display them to Text view.in above post of mine i have provided with the code of the samethere are no errors.it do get launch on emulator...but application is not retrieving the values of longitude and latitudeso... is there any kinda mistake in my code???...or what are the other reason of not getting latitude and longitude ..i have tried providing values from Emulator and command line..but it is not able to retain the values of latitude and longitude... thanks... On Jan 28, 11:26 am, TreKing wrote: > On Sat, Jan 28, 2012 at 12:04 AM, ajay talreja wrote: > > Is that “View.OnClickListener” listener only restricted to Layouts > > i.e. button Events etc > > Yes. You can look through the docs to see where it's used. > > > or it can be used to application click event…….example when application is > > double clicked ,dialer gets opened > > and when same application is single clicked , should get open... > > There is no concept of "clicking an application". You application, when > it's running, has some UI to display to the user - these UI elements can be > clicked, as described by the various listeners I linked you to. > > > is it possible…if yes….kindly help me with the code of the same….. > > Kindly explain what you're trying to do. > > > I have done coding to retrieve the latitude and longitude using gps > > but its not workinglocation is showing null value and finally it > > do not have any values of latitude and longitude. > > You need to explain this better. Maybe a SMALL sample of code where this is > "not working". > > - > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago > transit tracking app for Android-powered devices -- 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
[android-developers] Re: android help
Is that “View.OnClickListener” listener only restricted to Layouts i.e. button Events etc or it can be used to application click event…….example when application is double clicked ,dialer gets opened and when same application is single clicked , should get open...is it possible…if yes….kindly help me with the code of the same….. Other problems…. I have done coding to retrieve the latitude and longitude using gps but its not workinglocation is showing null value and finally it do not have any values of latitude and longitude. I have tried passing the values from Emulator control and also through command line using "telnet local host 5554(device name)". Also same is the case with Google maps ,I have tried to access Google maps but its not working via coding….i do have registered for Maps key…..but I am able to access Google maps application from emulator which is default present on emulator…I think so there is problem with the code…. im providing u with the code GPS only ,‘ll try for Google maps again.please go through it and reply sooner…. GPS 1) gps.java package d.gps; import android.app.Activity; import android.os.Bundle; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.widget.TextView; public class gps extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager locationManager; locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); updateWithNewLocation(location); } /** Update UI with a new location */ private void updateWithNewLocation(Location location) { TextView myLocationText = (TextView)findViewById(R.id.myLocationText); String latLongString; if (location != null) { double lat = location.getLatitude(); double lng = location.getLongitude(); latLongString = "Lat:" + lat + "\nLong:" + lng; } else { latLongString = "No location found"; } myLocationText.setText("Your Current Position is:\n" + latLongString); } } 2) main.xml http://schemas.android.com/apk/res/ android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > 3)String.xml Hello World, gps! gps 4) androidmanifest.xml http://schemas.android.com/apk/res/android"; package="d.gps" android:versionCode="1" android:versionName="1.0"> Thanks…… -- 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
[android-developers] android help
hii i'm an beginner in android... My problem in android... i want to send sms from a numeric touch pad via programming.. i m not able to find how to put up the code for numeric pad.i did google many times but im unable to find the same.the application should work same as speed dialrather than call,a sms will be sent..Im acquaint with Sms sending,database connectivity.i need the code to put my app working at press of any numeric key if this is not possible to make changes at Numeric pad,then help me for my other alternative to this...when application's shortcut is made condition if a normal press is encountered, setting activity should get opened and when long pressed ,sms should be sent without asking for anything... please help ..how to distinguish between single click and long pressed events via coding. thanks -- 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