GcmService.java 1017 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Feel free to copy/use it for your own project.
  3. * Keep in mind that it took me several days/weeks, beers and asperines to make this.
  4. * So be nice, and give me some credit, I won't bite and it won't hurt you.
  5. *
  6. * Created by Deben Oldert
  7. */
  8. package com.dev.deben.implementation;
  9. import android.os.Bundle;
  10. import android.os.SystemClock;
  11. import com.google.android.gms.gcm.GcmListenerService;
  12. import org.json.JSONException;
  13. import java.io.IOException;
  14. public class GcmService extends GcmListenerService {
  15. function fn = new function(this);
  16. @Override
  17. public void onMessageReceived(String from, Bundle data) {
  18. System.out.println("Msg from: " + from + ", " + data);
  19. try {
  20. fn.writeSetting("requestId", data.getString("requestId"));
  21. } catch (IOException | JSONException e) {
  22. e.printStackTrace();
  23. }
  24. int id = fn.notifier("Access control", "New VPN login request");
  25. SystemClock.sleep(30000);
  26. fn.cancelNotify(id);
  27. }
  28. }