fork download
  1. @Override
  2.  
  3. protected void onRegistered(Context context, String registrationId) {
  4.  
  5. //Log.d("GCM", "onRegistered: " + registrationId);
  6.  
  7.  
  8.  
  9. Log.i(TAG, "Device registered: regId = " + registrationId);
  10.  
  11.  
  12.  
  13. m_isUploadGCM = true;
  14.  
  15. CAllData.m_GCMToken = registrationId;
  16.  
  17. GetCSRF getCSRF = new GetCSRF();
  18.  
  19. getCSRF.execute();
  20.  
  21. }
  22.  
  23.  
  24.  
  25. @Override
  26.  
  27. protected void onUnregistered(Context context, String registrationId) {
  28.  
  29. Log.i(TAG, "Device unregistered");
  30.  
  31.  
  32.  
  33. if (GCMRegistrar.isRegisteredOnServer(context)) {
  34.  
  35. //ServerUtilities.unregister(context, registrationId);
  36.  
  37. } else {
  38.  
  39. Log.i(TAG, "Ignoring unregister callback");
  40.  
  41. }
  42.  
  43. }
  44.  
  45.  
  46.  
  47. @Override
  48.  
  49. protected void onMessage(Context context, Intent registrationId) {
  50.  
  51.  
  52.  
  53. Log.d("GCM", "RECIEVED A MESSAGE");
  54.  
  55. generateNotification(context, registrationId.getStringExtra("message"));
  56.  
  57. }
  58.  
  59.  
  60.  
  61. private static void generateNotification(Context context, String message) {
  62.  
  63. NotificationManager notificationManager = (NotificationManager) context
  64.  
  65. .getSystemService(Context.NOTIFICATION_SERVICE);
  66.  
  67. //Notification notification = new Notification(R.drawable.ic_launcher, message, when);
  68.  
  69. Notification notification = new NotificationCompat.Builder(context)
  70.  
  71. .setContentTitle("title")
  72.  
  73. .setContentText("text")
  74.  
  75. .setSmallIcon(R.drawable.ic_launcher)
  76.  
  77. .build();
  78.  
  79. Intent notificationIntent;
  80.  
  81. //Intent shareIntent = new Intent(Intent.ACTION_SEND);
  82.  
  83. //shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  84.  
  85.  
  86.  
  87. if( !CAllData.m_isNotificationOn)
  88.  
  89. return;
  90.  
  91.  
  92.  
  93.  
  94.  
  95. // set intent so it does not start a new activity
  96.  
  97. if( !CAllData.m_isInited)
  98.  
  99. notificationIntent = new Intent(context, Splash.class);
  100.  
  101. else
  102.  
  103. notificationIntent = new Intent();
  104.  
  105.  
  106.  
  107. notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  108.  
  109. //notification.setLatestEventInfo(context, title, message, intent);
  110.  
  111. notification.defaults = Notification.DEFAULT_SOUND;
  112.  
  113. notification.defaults |= Notification.DEFAULT_VIBRATE;
  114.  
  115. notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
  116.  
  117. notification.flags |= Notification.FLAG_AUTO_CANCEL;
  118.  
  119. notificationManager.notify(0, notification);
  120.  
  121. }
  122.  
  123.  
  124.  
  125. @Override
  126.  
  127. protected void onError(Context context, String registrationId) {
  128.  
  129. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class, interface, or enum expected
    protected void onRegistered(Context context, String registrationId) {
              ^
Main.java:13: error: class, interface, or enum expected
    	m_isUploadGCM = true;
    	^
Main.java:15: error: class, interface, or enum expected
    	CAllData.m_GCMToken = registrationId;
    	^
Main.java:17: error: class, interface, or enum expected
    	GetCSRF getCSRF = new GetCSRF();
    	^
Main.java:19: error: class, interface, or enum expected
        getCSRF.execute();        
        ^
Main.java:21: error: class, interface, or enum expected
    }
    ^
Main.java:27: error: class, interface, or enum expected
    protected void onUnregistered(Context context, String registrationId) {
              ^
Main.java:33: error: class, interface, or enum expected
        if (GCMRegistrar.isRegisteredOnServer(context)) {
        ^
Main.java:41: error: class, interface, or enum expected
        }
        ^
Main.java:49: error: class, interface, or enum expected
    protected void onMessage(Context context, Intent registrationId) {
              ^
Main.java:55: error: class, interface, or enum expected
        generateNotification(context, registrationId.getStringExtra("message"));
        ^
Main.java:57: error: class, interface, or enum expected
    }
    ^
Main.java:69: error: class, interface, or enum expected
        Notification notification = new NotificationCompat.Builder(context)
        ^
Main.java:79: error: class, interface, or enum expected
        Intent notificationIntent;
        ^
Main.java:87: error: class, interface, or enum expected
        if( !CAllData.m_isNotificationOn)
        ^
Main.java:97: error: class, interface, or enum expected
        if( !CAllData.m_isInited)
        ^
Main.java:99: error: <identifier> expected
        	notificationIntent = new Intent(context, Splash.class);
        	                                                     ^
Main.java:101: error: illegal start of type
        else
        ^
Main.java:101: error: ';' expected
        else
            ^
Main.java:103: error: illegal start of type
        	notificationIntent = new Intent();
        	                   ^
Main.java:103: error: <identifier> expected
        	notificationIntent = new Intent();
        	                    ^
Main.java:103: error: ';' expected
        	notificationIntent = new Intent();
        	                        ^
Main.java:103: error: illegal start of type
        	notificationIntent = new Intent();
        	                               ^
Main.java:103: error: <identifier> expected
        	notificationIntent = new Intent();
        	                                ^
Main.java:107: error: <identifier> expected
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                   ^
Main.java:107: error: <identifier> expected
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                  ^
Main.java:107: error: ';' expected
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                    ^
Main.java:107: error: illegal start of type
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                           ^
Main.java:107: error: ';' expected
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                                                  ^
Main.java:111: error: <identifier> expected
        notification.defaults = Notification.DEFAULT_SOUND;
                             ^
Main.java:113: error: <identifier> expected
        notification.defaults |= Notification.DEFAULT_VIBRATE;
                                                             ^
Main.java:115: error: <identifier> expected
        notification.flags |= Notification.FLAG_ONLY_ALERT_ONCE;
                                                               ^
Main.java:117: error: <identifier> expected
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
                                                           ^
Main.java:119: error: <identifier> expected
        notificationManager.notify(0, notification);
                                  ^
Main.java:119: error: illegal start of type
        notificationManager.notify(0, notification);
                                   ^
Main.java:119: error: <identifier> expected
        notificationManager.notify(0, notification);
                                                  ^
Main.java:127: error: class, interface, or enum expected
    protected void onError(Context context, String registrationId) {
              ^
37 errors
stdout
Standard output is empty