G. Plann

Greenhorn
+ Follow
since May 09, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by G. Plann

Thank you both for your insight. I will carefully read over what you said and do some more research.
10 years ago
I'm used to methods and classes being separated in the UI. To always HAVE TO place a public method in a class is a concept that I am just getting used to. You're not going to insult me if I fully understood this I wouldn't be in here asking questions. I do appreciate your courtesy though.

I appreciate the code examples. I do understand the syntax for classes and methods. I also have used THIS for context and tried to use getContext with some degree of success. I guess my issues must be with Android and the way it works with java as you mentioned is a bit different. I am used to OOP where you name it and call to it from anywhere if it is a global. Sometimes java doesn't even feel like an OOP to me with all this context stuff to contend with all the time.

If I name it myMethod and it's in the myClass class, I am used to just saying myClass.myMethod(params) and in java it seems like everytime I try and do this it complains about context.

I was hoping for some clarification on the rules of using context. Apparently it is as complicated as I thought.

It's funny I can write php with my eyes closed but this stuff drives me mad!

All my code ends up in one place because of this and I get this thousand line programs to hunt through. Where in other OOP languages I would just create one method and call to it over and over from anywhere. Nice and neat and organized.

Thanks for your help. I guess there isn't an easy answer.
10 years ago
Maybe I'm doing something wrong then because in eclipse I don't see a way to create a method, only classes. I would like to be able to organize my code better like I do in VB by separating the code into methods that are called from my main activity. I've tried to create classes for just this purpose but I'm always running into these context issues and I don't really understand context or the syntax to use it. Other than this context issue I get along with java just fine. Any help would be appreciated as I don't have any specific problem to solve at the moment but I am starting a new app and I was hoping to get a better grasp on this before I get into it. Thanks for your time.
10 years ago

Jeff Verdegan wrote:You mean the "problem" of having to have a context to pass?

Activity and Service both extend Context (indirectly), and ContentProvider has a getContext() method, so in a big chunk of the code we write, the Context is a given. Any other class we write--at least any class that's going to do anything requiring a context--is probably created and/or used by one of those components, so it's easy to give that class a Context.



Thanks for your reply. How do I use getContext to call an external class from any other class? Any examples or further information to help me understand Context would be great. I come from a VB background and this concept is still not sinking in completely.
10 years ago
Hello guys! Nice to meet you all!

When programming in android, how do I call a class(method) from any other class without running into context issues all the time?

Thanks.

10 years ago