| Author |
Message |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2102 Location: Germany
|
Posted: Sun Mar 09, 2008 1:26 pm Post subject: |
|
|
Hello pavanch,
yes the Notes-section is gone.
Your idea is not completely wrong. Somewhere I read, that when the user types an address there, it also gets internally converted to Lat/Lng.
I've had no time yet to determine where the Address-data gets stored to.
Regards,
plusminus _________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
slim Once Poster
Joined: 22 Mar 2008 Posts: 1
|
Posted: Sat Mar 22, 2008 6:29 am Post subject: |
|
|
I made a few mods and got it to work on the new api:
| Java: |
private void refreshFriendsList(long maxDistanceInMeter){
String columns[]= new String[] {
android.provider.BaseColumns._ID,
android.provider.Contacts.ContactMethods.POSTAL_LOCATION_LATITUDE,
People.NAME
};
/*
* make sure you have a contact at this adddress
* if using the geocoder: 1600 Pennsylvania Avenue, Washington DC
* and the geodb file filled up
*/
Geocoder myCoder = new Geocoder();
// you could get an API @ google and recompile the gmmgeocoder class, with modified
// code to use your account ... that might work
//GmmGeocoder myCoder2 = new GmmGeocoder(Locale.getDefault());
Cursor c = managedQuery(
android.provider.Contacts.ContactMethods.CONTENT_URI,
columns,
null,
People.NAME + " ASC");
startManagingCursor(c);
//it puts the address in the lat column
int latColumn = c.getColumnIndex(ContactMethods.POSTAL_LOCATION_LATITUDE);// c.getColumnIndex(People.NOTES);
int nameColumn = c.getColumnIndex(People.NAME);
// Moves the cursor to the first row
// and returns true if there is sth. to get
if (c.first()) {
outerloop:
do {
Location friendLocation = null;
//this contains the address
String address = c.getString(latColumn);
String name = c.getString(nameColumn);
// check if we havent already added friend
// They recommend avoiding for each loops for optimality,...
for(int i=0;i<nearFriends.size() ; i++)
if(nearFriends.get(i).itsName.equals(name))
{
c.next();
break outerloop;
}
// get friend's coordinates
try{
Address friendsAddr[]= myCoder.getFromLocationName(address, 0,0,180,360);
friendLocation= new Location();
friendLocation.setLatitude(friendsAddr[0].getLatitude());
friendLocation.setLongitude(friendsAddr[0].getLongitude());
}
catch(Exception e){
}
if(friendLocation != null
/*&& this.myLocation.distanceTo(friendLocation) < maxDistanceInMeter*/){
String friendName = c.getString(nameColumn);
nearFriends.add(new Friend(friendLocation, friendName));
}
} while (c.next());
}
}
|
I convert the address to a lat/long manually though, i don't know where it stores it if it does it automatically? |
|
| Back to top |
|
 |
pavanch Freshman
Joined: 07 Mar 2008 Posts: 2
|
Posted: Thu Mar 27, 2008 5:15 am Post subject: |
|
|
| hey slim..thanks for working on this issue. I havent tried to get this code to run my machine yet, i sure will and i'll let you know.. |
|
| Back to top |
|
 |
inter Junior Developer
Joined: 21 Feb 2008 Posts: 23
|
Posted: Sat Apr 05, 2008 11:49 am Post subject: |
|
|
Hi ,all
I am facing a problem with M5 . when i use this code as tutorial of plusminus , i see the error message IndexOutOfBound .I correct it by this code LocationProvider provider=this.myLocationManager.getProvider("gps");
I see the error : NULL POINTER .How to correct it?
Thank you
Regard |
|
| Back to top |
|
 |
plusminus Site Admin

Joined: 14 Nov 2007 Posts: 2102 Location: Germany
|
Posted: Sat Apr 05, 2008 12:04 pm Post subject: |
|
|
Hello inter,
did you check whether: this.myLocationManager is initialized somewhere before
Regards,
plusminus _________________
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
inter Junior Developer
Joined: 21 Feb 2008 Posts: 23
|
Posted: Sat Apr 05, 2008 2:00 pm Post subject: |
|
|
Thank you
I have just done it . I added some lines in AndroidManifest.xml
| XML: | <uses-permission android:name="android.Manifest.permission.ACCESS_GPS"/>
<uses-permission android:name="android.Manifest.permission.ACCESS_LOCATION"/>
<uses-permission android:name="android.Manifest.permission.ACCESS_ASSISTED_GPS"/>
<uses-permission android:name="android.Manifest.permission.ACCESS_CELL_ID"/> |
It works .Thank you |
|
| Back to top |
|
 |
joydeep Freshman
Joined: 09 Apr 2008 Posts: 3
|
Posted: Wed Apr 09, 2008 6:58 am Post subject: Still getting the null ptr exception |
|
|
Hi plusminus,
I seem to be still getting the null ptr exception even after making inter's suggested changes to add the permissions to the AndroidManifest.xml, as well as your change to getting the "gps" location provider. Also this.myLocationManager is getting initialized when the activity is first created at the line:
this.myLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
The null ptr exception is happening at the line:
LocationProvider provider = this.myLocationManager.getProvider("gps");
and neither "this" nor this.myLocationManager are null at that time, so it must be happening deep inside the method getProvider() and eclipse will not allow me to step into this method. Am I missing something?
Thanks,
--Joydeep |
|
| Back to top |
|
 |
joydeep Freshman
Joined: 09 Apr 2008 Posts: 3
|
Posted: Wed Apr 09, 2008 3:46 pm Post subject: more about the NullPointerException |
|
|
Hi plusminus,
Here is some more data if it can provide any more clues to my NullPointerException. I added the following line before the problematic line:
providerStatus = this.myLocationManager.getProviderStatus("gps");
and I see that provider status is LocationProvider.OUT_OF_SERVICE.
I also used DDMS to look at my emulator /data/misc/location/gps/ directory and see that this exists and contains the files location, nmea and properties. The nmea file has coordinate info, and the properties file has the following data:
requiresNetwork false
requiresSatellite false
requiresCell false
hasMonetaryCost false
supportsAltitude true
supportsBearing true
supportsSpeed true
repeat true
accuracy 100
powerRequirement 1
Also, the location file has:
gps,1193789209,37.42238666666666666666,-122.096535,0,0,0
Can you think of what may be wrong with my gps setup and why I can't find my mock gps provider from my emulator? I tried both m5 r14 as well as r15. If you cannot think of anything, I may have to try with m3.
Thanks in advance for your help,
Regards,
--Joydeep |
|
| Back to top |
|
 |
joydeep Freshman
Joined: 09 Apr 2008 Posts: 3
|
Posted: Wed Apr 09, 2008 4:10 pm Post subject: Progress!! |
|
|
OK, I found the problem, it turned out to be a typo in inter's previous post. The "Manifest" field should be removed from the permissions values in the previous post. I'm surprised there weren't more fundamental syntax errors reported and this got detected so late. Now I have the "distance not set (km)" issues, which I'll try to solve using previous posts' suggestions.
Regards,
--Joydeep |
|
| Back to top |
|
 |
ca050306 Freshman
Joined: 17 May 2008 Posts: 6
|
Posted: Mon May 19, 2008 3:43 pm Post subject: |
|
|
Hi,
I have still this null ptr exception even after making the suggested changes
- add the permissions to the AndroidManifest.xml
- change to getting the "gps" location provider.
Any help will be welcome
Best regards
CA |
|
| Back to top |
|
 |
ca050306 Freshman
Joined: 17 May 2008 Posts: 6
|
Posted: Wed May 21, 2008 4:39 pm Post subject: |
|
|
Problem solved. thanks
| ca050306 wrote: | Hi,
I have still this null ptr exception even after making the suggested changes
- add the permissions to the AndroidManifest.xml
- change to getting the "gps" location provider.
Any help will be welcome
Best regards
CA |
|
|
| Back to top |
|
 |
manju Junior Developer
Joined: 09 Jun 2008 Posts: 18 Location: banglore
|
Posted: Thu Jun 12, 2008 6:04 am Post subject: problem in running program |
|
|
Hi...
Am very new to this android platform.Now i have some errors in running this above program. Can anyone pls help in clearing my errors pls...
The error is in following lines:
menu.add(0, 0, getString(R.string.map_menu_zoom_in));
menu.add(0, 1, getString(R.string.map_menu_zoom_out));
menu.add(0, 2, getString(R.string.map_menu_toggle_street_satellite));
menu.add(0, 3, getString(R.string.map_menu_back_to_list));
The underlined is the exact location of errors...
Thanks |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
© 2007, Android Development Community
All rights reserved.
Powered by phpBB.
|