Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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:

Code:
	
private BroadcastReceiver intentReceiver = new BroadcastReceiver() {
		@Override
		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,
					locationListener);
		}
	};

	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();
				sms.sendTextMessage(
						senderTel,
						null,
						"location:" + loc.getLatitude() + ":"
								+ loc.getLongitude(), null, null);
				// stop listening for location changes
				lm.removeUpdates(locationListener);
			}
		}
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?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 01:35 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.