fork download
  1. //Application
  2. package com.tutorial.Alert;
  3.  
  4. import android.app.Application;
  5.  
  6. import com.parse.Parse;
  7. import com.parse.ParseACL;
  8. import com.parse.ParseInstallation;
  9. import com.parse.ParseObject;
  10. import com.parse.ParseUser;
  11.  
  12. public class SampleApplication extends Application {
  13. @Override
  14. public void onCreate() {
  15. // TODO Auto-generated method stub
  16. super.onCreate();
  17. ParseObject.registerSubclass(Alert.class);
  18. Parse.initialize(this, "ABC", "XYZ");
  19. ParseInstallation.getCurrentInstallation().saveInBackground();
  20. ParseUser.enableAutomaticUser();
  21. ParseACL defaultACL = new ParseACL();
  22. ParseACL.setDefaultACL(defaultACL, true);
  23. }
  24.  
  25. }
  26.  
  27. //Subclass
  28. package com.tutorial.Alert;
  29.  
  30. import com.parse.ParseClassName;
  31. import com.parse.ParseObject;
  32. import com.parse.ParseQuery;
  33.  
  34. @ParseClassName("Alert")
  35. public class Alert extends ParseObject {
  36. public String getTitle()
  37. {
  38. return getString("title");
  39. }
  40.  
  41. public String getCategory()
  42. {
  43. return getString("category");
  44. }
  45. public String getDescription()
  46. {
  47. return getString("description");
  48. }
  49.  
  50. public static ParseQuery<Alert> getQuery() {
  51. return ParseQuery.getQuery(Alert.class);
  52. }
  53.  
  54. }
  55.  
  56. //MainActivity where you retrieve data
  57. package com.tutorial.Alert;
  58.  
  59. import java.util.List;
  60.  
  61. import android.content.Context;
  62. import android.net.ConnectivityManager;
  63. import android.net.NetworkInfo;
  64. import android.os.Bundle;
  65. import android.support.v7.app.ActionBarActivity;
  66. import android.util.Log;
  67.  
  68. import com.parse.CountCallback;
  69. import com.parse.FindCallback;
  70. import com.parse.ParseException;
  71. import com.parse.ParseQuery;
  72.  
  73.  
  74. public class MainActivity extends ActionBarActivity {
  75. public static final String TAG = "AlertMainActivity";
  76.  
  77. @Override
  78. protected void onCreate(Bundle savedInstanceState) {
  79. super.onCreate(savedInstanceState);
  80. setContentView(R.layout.activity_main);
  81. }
  82.  
  83. @Override
  84. protected void onResume() {
  85. // TODO Auto-generated method stub
  86. super.onResume();
  87.  
  88. ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  89. NetworkInfo ni = cm.getActiveNetworkInfo();
  90. if ((ni != null) && (ni.isConnected())) {
  91. ParseQuery<Alert> query = Alert.getQuery();
  92. query.whereEqualTo("category", "Serious");
  93. Log.d(TAG,"before calling query");
  94. query.findInBackground(new FindCallback<Alert>() {
  95. public void done(List<Alert> list, ParseException exp)
  96. {
  97. if(exp == null){
  98. for(int i=0;i<list.size();i++)
  99. {
  100. Alert alert = list.get(i);
  101. Log.d(TAG, "Title = "+ alert.getTitle() + " desc = "+ alert.getDescription());
  102. }
  103.  
  104. } else {
  105. Log.d(TAG,"no results !!"+ exp.getMessage()+" code ="+ exp.getCode());
  106. }
  107. };
  108.  
  109. });
  110. } else{
  111. if(null == ni)
  112. Log.d(TAG, "ni is null");
  113. if(!ni.isConnected())
  114. Log.d(TAG,"network is not connected");
  115. }
  116.  
  117.  
  118. }
  119.  
  120. }
  121.  
  122. <?xml version="1.0" encoding="utf-8"?>
  123. <manifest xmlns:android="http://s...content-available-to-author-only...d.com/apk/res/android"
  124. package="com.tutorial.Alert"
  125. android:versionCode="1"
  126. android:versionName="1.0" >
  127.  
  128. <uses-sdk
  129. android:minSdkVersion="9"
  130. android:targetSdkVersion="21" />
  131. <uses-permission android:name="android.permission.INTERNET" />
  132. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  133. <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  134. <uses-permission android:name="android.permission.VIBRATE" />
  135. <uses-permission android:name="android.permission.WAKE_LOCK" />
  136. <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  137. <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  138.  
  139. <permission android:name="com.tutorial.Alert.permission.C2D_MESSAGE"
  140. android:protectionLevel="signature" />
  141. <uses-permission android:name="com.tutorial.Alert.permission.C2D_MESSAGE" />
  142.  
  143. <application
  144. android:name="com.tutorial.Alert.SampleApplication"
  145. android:allowBackup="true"
  146. android:icon="@drawable/ic_launcher"
  147. android:label="@string/app_name"
  148. android:theme="@style/AppTheme" >
  149. <activity
  150. android:name=".MainActivity"
  151. android:label="@string/app_name" >
  152. <intent-filter>
  153. <action android:name="android.intent.action.MAIN" />
  154.  
  155. <category android:name="android.intent.category.LAUNCHER" />
  156. </intent-filter>
  157. </activity>
  158.  
  159. <service android:name="com.parse.PushService" />
  160. <receiver android:name="com.parse.ParseBroadcastReceiver">
  161. <intent-filter>
  162. <action android:name="android.intent.action.BOOT_COMPLETED" />
  163. <action android:name="android.intent.action.USER_PRESENT" />
  164. </intent-filter>
  165. </receiver>
  166. <receiver android:name="com.parse.GcmBroadcastReceiver"
  167. android:permission="com.google.android.c2dm.permission.SEND">
  168. <intent-filter>
  169. <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  170. <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
  171.  
  172. <!--
  173. IMPORTANT: If you change the package name of this sample app,
  174. change "com.parse.tutorials.pushnotifications" in the lines
  175. below to match the new package name.
  176. -->
  177. <category android:name="com.tutorial.Alert" />
  178. </intent-filter>
  179. </receiver>
  180. </application>
  181.  
  182. </manifest>
  183.  
  184.  
  185.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:11: error: class ExamApplication is public, should be declared in a file named ExamApplication.java
public class ExamApplication extends Application {
       ^
Main.java:3: error: package android.app does not exist
import android.app.Application;
                  ^
Main.java:5: error: package com.parse does not exist
import com.parse.Parse;
                ^
Main.java:6: error: package com.parse does not exist
import com.parse.ParseACL;
                ^
Main.java:7: error: package com.parse does not exist
import com.parse.ParseInstallation;
                ^
Main.java:8: error: package com.parse does not exist
import com.parse.ParseObject;
                ^
Main.java:9: error: package com.parse does not exist
import com.parse.ParseUser;
                ^
Main.java:11: error: cannot find symbol
public class ExamApplication extends Application {
                                     ^
  symbol: class Application
Main.java:12: error: method does not override or implement a method from a supertype
	@Override
	^
Main.java:15: error: cannot find symbol
		super.onCreate();
		^
  symbol:   variable super
  location: class ExamApplication
Main.java:16: error: cannot find symbol
		ParseObject.registerSubclass(ExamAlert.class);
		                             ^
  symbol:   class ExamAlert
  location: class ExamApplication
Main.java:16: error: cannot find symbol
		ParseObject.registerSubclass(ExamAlert.class);
		^
  symbol:   variable ParseObject
  location: class ExamApplication
Main.java:17: error: cannot find symbol
		Parse.initialize(this, "fH56QasJigH5g8AJWAOXDmEbfKXCL8Gdqi1wlEaI", "NT1fDzvuaugCcEdsvEFJt8mk9BevPcx0urzRDDBo");
		^
  symbol:   variable Parse
  location: class ExamApplication
Main.java:18: error: cannot find symbol
		ParseInstallation.getCurrentInstallation().saveInBackground();
		^
  symbol:   variable ParseInstallation
  location: class ExamApplication
Main.java:19: error: cannot find symbol
		ParseUser.enableAutomaticUser();
		^
  symbol:   variable ParseUser
  location: class ExamApplication
Main.java:20: error: cannot find symbol
		ParseACL defaultACL = new ParseACL();
		^
  symbol:   class ParseACL
  location: class ExamApplication
Main.java:20: error: cannot find symbol
		ParseACL defaultACL = new ParseACL();
		                          ^
  symbol:   class ParseACL
  location: class ExamApplication
Main.java:21: error: cannot find symbol
		ParseACL.setDefaultACL(defaultACL, true);	
		^
  symbol:   variable ParseACL
  location: class ExamApplication
18 errors
stdout
Standard output is empty