Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ks3dev/38d56171f933c410108c to your computer and use it in GitHub Desktop.
Save ks3dev/38d56171f933c410108c to your computer and use it in GitHub Desktop.
//1-create an interface on separated class as :
import java.util.EventListener;
public interface post2socialInterface extends EventListener {
public void responseResult(String val);
}
//2-at original class is like that :
public class post2social {
// Used to communicate the result back to the Activity
public post2socialInterface listener;
.
.
.
//in a method raise the event like :
listener.responseResult("Message posted on " + provider);
.
.
.
//make the setListener on your own!
public void setListener(post2socialInterface listener) {
this.listener = listener;
}
}
//then at activity
post2social s = new post2social(Test.this, "", "", "", "", "", );
s.setListener(new post2socialInterface() {
@Override
public void responseResult(String val) {
final String tmp = val;
runOnUiThread(new Runnable() {
public void run() {
if (progress != null)
progress.dismiss();
Toast.makeText(TestActivity.this,tmp, Toast.LENGTH_LONG).show();
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment