• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

How i can call the value from other class

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys, im stuck with this.

i have this code on mainactivity

then in a class called personal

i need call the iso code. i try with youtube tutorials but the teacher only display the info on the same main activity, and if i create the method on the class "personal" y got errors.
exactly



thanks in advance

 
Rancher
Posts: 121
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you need to call this method on the instance of the class, unless it's a static method than you use it like this: SomeClass.someMethod()
 
Saloon Keeper
Posts: 2806
367
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getSystemService comes from the Activity class.

Does your MainActivity class extend Activity?
 
German Hernandez
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks both answers:

1) y try


2)
i have
y test with:
public class Personal extends MainActivity and i can't use

again, i think i have a misunderstood with the clases in java
 
Ron McLeod
Saloon Keeper
Posts: 2806
367
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is more common to use system services inside activities, services, broadcast receivers, content providers, and other Android components.  If not, then a class wanting to access a system service will need to be provided application context somehow, as shown in this example code:
 
He's my best friend. Not yours. Mine. You can have this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!