Reputation: 4864
Is it possible to call a particular method that's in an Activity from a widget?
This is the method I would like to call:
/*
* Close out this screen.
*/
private void finishThisActivity() {
this.finish();
} // End method finishThisActivity.
If this can be done, can you show some sample code?
Upvotes: 0
Views: 209
Reputation: 450
i will like to share my idea that if you want to call your own method finishThisActivity() from widget then you need to use a tag called "android:onclick="methodname".For you the method name should be "finishThisActivity".
EXAMPLE: Suppose you want to call this method in place of onClick() in case of Button then you need to use the above tag for button and you need to put the corresponding method
private void finishThisActivity() {
this.finish();
}
outside of onCreate()
Upvotes: 1