aspose file tools*
The moose likes Android and the fly likes String not passing to class that extends Activity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "String not passing to class that extends Activity" Watch "String not passing to class that extends Activity" New topic
Author

String not passing to class that extends Activity

Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
Hello,

My classes are calculating and doing the math properly but when I try to pass a string answer to the main class Assignment2Activity.java it show up as null. I'm conducting system.out.println line throughout the project to confirm that my answers are showing up and are correct but when I try to pass the string to the class that extends Activity it fails. But if I try to pass the string to the driver or calculations class it works fine. Any thoughts? I created a getAnswerPassed() and getAnswerToPass in the TimeDifferenceDriver and TimeDifference classes to see if that would change anything and it still shows up as null in the Assignment2Activity class. I've been looking up info on the web and it seems that by extending activity it makes things more difficult, is that true? Any help is appreciated. Thanks








Mario Alcantara
Greenhorn

Joined: Mar 29, 2011
Posts: 16
Your problem is not with the class that extends Activity, you have a basic logic problem, in the method getAnswerPassed() of the class TimeDifferenceDriver you are creating an object of type TimeDifference and all properties or instance variables are initialized to default value and a default value of String is null. Once created the object TimeDifference you immediately call method getAnswerToPass() and you get null.

I hope help you and sorry by my english
Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
Thank you that was pretty much it. I combined the TimeDifference.java and TimeDifferenceDriver.java into the Calculations.java class. Originally I thought the classes were getting too large but the teacher says compared to a real word development environment they were tiny. Also Mario your English was fine.
Thanks again.
 
 
subject: String not passing to class that extends Activity