fish man
fish man

Reputation: 101

new to android - need to access bitmap object from another class

class1 has this method:

private Bitmap scaleImage() { 
Bitmap nad =    BitmapFactory.decodeFile(path);

return nad;
}

I need to use this nad object in class2...I tried to look through some java documentation on access class properties,but nothing worked..

Upvotes: 1

Views: 367

Answers (1)

leo9r
leo9r

Reputation: 2047

You have declared you method as private. That prevents other classes from invoking it. You usually use the private modifier to guarantee encapsulation, but for your case you should use:

  • public, meaning that any other class can invoke scaleImage(), or,
  • protected to restrict it to the classes inheriting from class1 and the classes in its same package, or,
  • Use no modifier at all, which will allow access to the classes in the same package (This is the default behavior, also known as package-private).

For further details on access modifiers: http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

Upvotes: 1

Related Questions