Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android 2 Application Development
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Android 2 Application Development
This is the forum to discuss the Wrox book Professional Android 2 Application Development, 2nd Edition by Reto Meier; ISBN: 978-0-470-56552-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android 2 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 July 28th, 2010, 11:11 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 7 Earthquake 2, Earthquake.java, error onActivityResult

I am pretty sure there is an error in the file Earthquake.java
When the user sets a preference and thus the requestCode== SHOW_PREFERENCES , the result of the context menu will not send the desired Activity.RESULT_OK value.

Here is my fix. Any feedback is appreciated.
//BEGINNING OF PROPOSED FIX
Code:
 
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
//REMOVED super.onActivityResult(requestCode, resultCode, data);

      if (requestCode == SHOW_PREFERENCES)
//REMOVED if (resultCode == Activity.RESULT_OK) 

    	  { 
          updateFromPreferences();
          refreshEarthquakes();
           } 
      
//ADDED:
      else{
    	  super.onActivityResult(requestCode, resultCode, data);
      }
//END OF ADDED CODE
    }
//END OF THIS POST

Last edited by dbomberg; July 28th, 2010 at 11:14 PM.. Reason: adding tags [code] and [/code]
  #2 (permalink)  
Old November 30th, 2012, 05:34 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default refreshEarthquakes method

Hi,
Thanx for your workaround. Can you give the code for the refreshEarthquakes(); method ? Or is this part correct in the book ?
Herwig
  #3 (permalink)  
Old November 30th, 2012, 05:52 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working code for OnAcivityResult Earthquakes

Hi,

Here is the code that works, and replaces the code on page 231


Code:
public void onActivityResult(int requestCode, int resultCode, Intent data) 
	{
		if (requestCode == SHOW_PREFERENCES)
		{ 
			updateFromPreferences();				 
	        Thread thread = new Thread(new Runnable()
	        {
	        	public void run()
	        	{
	        		FragmentManager fragmentManager = getFragmentManager();
	    	        EarthquakeListFragment earthquakeList = 
	    	          (EarthquakeListFragment)fragmentManager.findFragmentById(R.id.EarthquakeListFragment);
	        		earthquakeList.refreshEarthquakes();
	        	}
	        });
	        thread.start();
		} 
		else
		{
			super.onActivityResult(requestCode, resultCode, data);
		}
    }
Regards,
Herwig


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 9 - Earthquake - TimerTask Error IAmCorbin BOOK: Professional Android 2 Application Development 2 November 2nd, 2010 04:50 PM
Please help: Chapter 9 Earthquake 4 dahe BOOK: Professional Android 2 Application Development 0 July 21st, 2010 03:41 PM
chapter 5 Earthquake EricTapia BOOK: Professional Android 2 Application Development 2 April 14th, 2010 12:47 AM
Chapter 8 Earthquake Notification woods620 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 1 December 23rd, 2009 09:57 AM
Chapter 6 Sample Earthquake 2 sunrain BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 January 31st, 2009 04:06 PM





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