Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public class MyCallingClass extends ActivityBase {
  2. private String _result = null;
  3.  
  4. protected void onCreate(Bundle savedInstanceState) {
  5. callingMethod();
  6. }
  7.  
  8. protected void callingMethod() {
  9. MyASyncClass whatever = new MyASyncClass(new MyASyncClass.AsyncResponse() {
  10. @Override
  11. **void processFinish(String output)**{
  12. _result = output;
  13. }
  14. }).execute();
  15. }
  16.  
  17. // More work done here
  18. }
  19.  
  20. public class MyASyncClass extends AsyncTask<String, String, String> {
  21. public interface AsyncResponse {
  22. void processFinish(String output);
  23. }
  24.  
  25. public AsyncResponse delegate = null;
  26.  
  27. public DeviceConnect(AsyncResponse delegate){
  28. this.delegate = delegate;
  29. }
  30.  
  31. @Override
  32. protected String doInBackground(String... params) {
  33. // Does the work
  34. }
  35.  
  36. @Override
  37. public void onPostExecute(String result) {
  38. delegate.processFinish(result);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement