Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 5th, 2011, 08:00 PM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conundrum w. chapter 5

I'm trying to create the apps in chapter 5 to send and respond to SMSes.

I'm making pretty good progress, but I am never getting to the "onLocationChanged()" event - I've got a breakpoint there, and although the locationListener is created, and requestLocationUpdates() is called, I never even get to the "if (loc != null) {
" line.

Here is my code:

private BroadcastReceiver intentReceiver = new BroadcastReceiver() {
		public void onReceive(Context context, Intent intent) {
			// get sender phone num passed via intent
			senderTel = intent.getExtras().getString("senderTel");

			// use the LocationManager class to obtain location data
			lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

			// request location updates
			// Change some of these args? First is minimum Time, second is
			// minimum Distance
			locationListener = new MyLocationListener();
			lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,

	private class MyLocationListener implements LocationListener {
		// @Override - got err msg on this - must override a superclass method
		public void onLocationChanged(Location loc) {
			if (loc != null) {
				// send a SMS containing the current location
				SmsManager sms = SmsManager.getDefault();
						"location:" + loc.getLatitude() + ":"
								+ loc.getLongitude(), null, null);
				// stop listening for location changes
I'm sending an SMS from DDMS from 5558 to 5554; it's being received, and parsed correctly, but for some reason MyLocationListener() is not getting fired. Does anybody have an idea why?

BTW, the top of p. 169 says "modify main.xml" where it should actually be the manifest file that's being modified, right?
And p. 168, the super.onPause() should be super.onDestroy(), correct?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Update query conundrum! timoma Access 4 April 1st, 2005 02:04 PM
Excel VBA - Wordwrap conundrum Shack Excel VBA 1 May 21st, 2004 06:12 AM
AutoNumber Conundrum enterbase Access VBA 4 January 28th, 2004 05:29 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.