Reputation:
I want the class MyContent.class wil be used in others projects, like a library, but it's posible to pass the code will be used inside the onChange when I create it?
MyContent.class
public class MyContent extends ContentObserver {
@Override
public void onChange(boolean selfChange, Uri uri) {
}
}
Main.class:
public class Main extends AsyncTask {
MyContent myContent= new MyContent(new Handler());
@Override
public void myContent.onChange(boolean selfChange, Uri uri) {
//posibility to use the uri parameter
Log.d("d", "onChange fired");
}
}
Output: OnChange fired*
Upvotes: 2
Views: 8520
Reputation: 33466
You can create an anonymous class which inherits from MyContent
and overrides the method:
public class Main extends AsyncTask {
MyContent myContent = new MyContent(new Handler()) {
@Override
public void onChange(boolean selfChange, Uri uri) {
//posibility to use the uri parameter
Log.d("d", "onChange fired");
}
};
}
Upvotes: 4