The Friend Finder - MapActivity using GPS - FULL SOURCE

Tutorials that use the MapActivity. Many using GPS functionality.

Postby rmeph » Fri Dec 21, 2007 1:22 pm

i debugger code but not problem in code
when i started application ......in starting show error.
Code: Select all
"org.anddev.android.friendfinder unable to start activity ComponentInfo {org.anddev.android.friendfinder/org.anddev.android.friendfinder.FriendFinder}:java.lang.IndexOutofBoundsException"
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Top

Postby plusminus » Fri Dec 21, 2007 5:07 pm

Hello rmeph,

without the line the error occurs, we cannot help much :)
Does it happen on startup or when you click sth. :?:

Did you create some Contacts before :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

LocationSpot on Map is not updated (repainted)!

Postby navajo » Fri Dec 21, 2007 6:38 pm

Hi plusminus,

as i run ur code for first few times, the appl. worked properly, but now the spot position is not repainted anymore. Coordinates and distance are updated, but not the spot position on map.
This happened first time as i tried to center the map according to the actual position. I changed the code and than, after compile and relaunch repainting stopped. So i reversed all changes but still there is no repainting!
I even set a complete new project in eclipse and reused ur code there-->same problem. I moved the appl. out of emulator, tried all what came to my mind with adb_server commands, deleted tmp data of emulator... nothing helped. The rest is well-oiled except repainting the map...
I m using WinXP SP2 with Eclipse IDE and latest JDK.
Any idea what i can do more to solve this?
And one more question: is there a efficient way to center map to a actual locationSpot, so the map moves and not my location?

Many thanks to a helpful code!
In a world without walls and fences... who needs Windows and Gates?
navajo
Junior Developer
Junior Developer
 
Posts: 15
Joined: Fri Dec 21, 2007 5:55 pm
Location: Germany

Postby plusminus » Fri Dec 21, 2007 9:26 pm

Hello navajo,

hard to say what is wrong with your code...

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.myMapView = new MapView(this);
  2.  
  3. this.myMapView.getController().centerMapTo(point, updateSelection);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby rmeph » Sat Dec 22, 2007 7:53 am

yes it's was happend on startup.........yes i created contacts before start application...........i debugger code but not problem in any line.....how to solved it? :cry:
rmeph
Senior Developer
Senior Developer
 
Posts: 121
Joined: Mon Dec 10, 2007 1:54 pm
Location: India

Postby plusminus » Sat Dec 22, 2007 5:18 pm

Hello rmeph,

the error should also occur, when you do "live"-debugging...
Set a breakpoint to the first line of every function and go through step by step.
Without the line we cannot really help :(

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

ZIP

Postby Constantine » Mon Jan 14, 2008 1:53 am

Thank you for the work!
Can I please download this sample in a single zip file?
Constantine
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 14, 2008 1:29 am

Postby plusminus » Mon Jan 14, 2008 8:27 am

Hello Constantine,

I just added it to the end of the first post as an attachment.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

a better regexp for a geotag

Postby shakespit » Fri Jan 25, 2008 6:04 pm

Hi plusminus!

I wrote a more powerful regular expression for geotags and moved it's compilation out from a do-while loop.

I expect geotag in following format:
Code: Select all
geo: +/-lat (-90 to 90), +/-lng (-180 to 180) [, +/-alt]

(based on http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00 ) and regexp catches lat, lng and alt in groups 1, 5 and 13 respectively.

So no more # in geotag is required but it's ok if it'l stay there

I think that static function with a regexp parser will be more convinient, but anyway, here is my version of a refreshFriendsList ():
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         private void refreshFriendsList(){
  3.  
  4.                 Cursor c = getContentResolver().query(People.CONTENT_URI,
  5.  
  6.                                 null, null, null, People.NAME + " ASC");
  7.  
  8.                 /* This method allows the activity to take
  9.  
  10.          * care of managing the given Cursor's lifecycle
  11.  
  12.          * for you based on the activity's lifecycle. */
  13.  
  14.                 startManagingCursor(c);
  15.  
  16.  
  17.  
  18.                 int notesColumn = c.getColumnIndex(People.NOTES);
  19.  
  20.                 int nameColumn = c.getColumnIndex(People.NAME);
  21.  
  22.  
  23.  
  24.                 // Moves the cursor to the first row
  25.  
  26.                 // and returns true if there is sth. to get
  27.  
  28.                 if (c.first()) {
  29.  
  30.                         // Pattern for extracting geo-ContentURIs from the notes.
  31.  
  32.                         final String geoPattern = "\\bgeo:\\s*([-+]?(90(\\.0*)?|[0-8]?[0-9](\\.[0-9]*)?))\\s*," + "\\s*([-+]?(1(80(\\.0*)?|[0-7]?[0-9](\\.[0-9]*)?)|([0-9]{1,2}(\\.[0-9]*)?)))(\\s*,\\s*([-+]?[0-9]*(\\.[0-9]*)?))?\\b";
  33.  
  34.                         // Compile and use regular expression
  35.  
  36.                         Pattern pattern = Pattern.compile(geoPattern);
  37.  
  38.  
  39.  
  40.                         do {           
  41.  
  42.                                 String notesString = c.getString(notesColumn);
  43.  
  44.                                
  45.  
  46.                                 Location friendLocation = null;
  47.  
  48.                                 if (notesString != null) {
  49.  
  50.                                         CharSequence inputStr = notesString;
  51.  
  52.                                         Matcher matcher = pattern.matcher(inputStr);
  53.  
  54.  
  55.  
  56.                                         if (matcher.find()) {
  57.  
  58.                                                 Double latid = Double.parseDouble(matcher.group(1));
  59.  
  60.                                                 Double longit = Double.parseDouble(matcher.group(5));
  61.  
  62.                                                
  63.  
  64.                                                 friendLocation = new Location();
  65.  
  66.  
  67.  
  68.                                                 friendLocation.setLatitude(latid.doubleValue());
  69.  
  70.                                                 friendLocation.setLongitude(longit.doubleValue());
  71.  
  72.                                                
  73.  
  74.                                         }
  75.  
  76.                                 }
  77.  
  78.                                 String friendName = c.getString(nameColumn);
  79.  
  80.                                 allFriends.add(new Friend(friendLocation, friendName));
  81.  
  82.                         } while (c.next());
  83.  
  84.                 }
  85.  
  86.         }
  87.  
  88.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
shakespit
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jan 25, 2008 5:42 pm

Postby plusminus » Fri Jan 25, 2008 6:48 pm

Hi shakespit,

oops :oops:, of course pulling the pattern-compile out of the loop is very wise :!:

Thx for sharing your thoughts.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Application not Responding

Postby hama » Wed Jan 30, 2008 1:05 pm

Hi, all

I have often experienced the alert of "Application not Responding".
The following warnings also appear in logcat.

W/ActivityManager( 465): Timeout of broadcast BroadcastRecord{4021f050 android.intent.action.LOCATION_CHANGED}
W/ActivityManager( 465): Receiver during timeout: BroadcastFilter{4020b368 android.app.IIntentReceiver$Stub$Proxy@4020b0d0}

I noticed that onReceiveIntent() is called in a chunky manner when such warnings/alert appear.
Does anyone have an idea why it occurs or how to fix it?

Thanks,

hama
hama
Freshman
Freshman
 
Posts: 2
Joined: Fri Dec 28, 2007 9:30 am

Re: Application not Responding

Postby plusminus » Wed Jan 30, 2008 6:22 pm

Hello hama,

the following message means that there was no IntentReceiver that wanted to receive our custom "android.intent.action.LOCATION_CHANGED"-Action.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. W/ActivityManager(  465): Timeout of broadcast BroadcastRecord{4021f050 android.intent.action.LOCATION_CHANGED}
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

As FriendFinder-application is the only application aware of this intent, there is probably something wring with your code. With me it works all fine.

Regards,
plusminu
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Including Search and Direction options in FriendFinder

Postby nisha » Fri Feb 15, 2008 8:04 am

hi plusminus,

I am new to android.. i tried ur friendfinder and it is really good.. Can you tel me how to include search and direction options, so that i can get the complete path to reach my friend.. which is similar to cellidtolatlong tutorial..

It would be nice if you reply me as early as possible..

Thanks :lol:
nisha
Experienced Developer
Experienced Developer
 
Posts: 80
Joined: Fri Feb 15, 2008 7:52 am

Postby plusminus » Fri Feb 15, 2008 11:11 am

Hello nisha,

there already is a :src: Driving-Directions Tutorial.
Which way made for m3-xxx SDK but should work for m5 (new SDK) with very slight changes.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Re: Emulator error :)

Postby intellibitz » Wed Feb 20, 2008 3:46 pm

The following permission needs to be added to AndroidManifest, if you are using the latest m5 release.

<uses-permission android:name="android.permission.ACCESS_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_GPS"/>

After running, I'm getting the same error as venkat. Probably the GPS not supports anything other than SF area. I remember reading something along those lines in the docs.

venkat wrote:Dear +/-,
while i am running your code i am getting my Contacts displaying like below,

zzzzzzzz (not set km)
xyzzzzzw(not set km)
abcdeww(not set km)


it's not handling click event at all. it's displaying nothing. can you tell me what is may be the error ???

Thanks in advance,

regards,
venkat :?:
http://intellibitz.com
We develop innovative solutions for mobile handsets, using Android.
intellibitz
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Feb 20, 2008 3:22 pm
Location: Chennai, TamilNadu, India.

Top
PreviousNext

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests