@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); /* This line gets the unique id associated with each android device. Can only be reset by wiping the phone */ final String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); Log.d("ANDROID ID", android_id); ParseQuery<ParseUser> query = ParseUser.getQuery(); query.whereEqualTo( "androidID", android_id); // If these id's match, an account has already been registered on that account query.findInBackground( new FindCallback<ParseUser>() { public void done(List<ParseUser> scoreList, ParseException e) { if (e == null) { if (scoreList.size() > 0) { Log.d("id", "android_id matches one already in the table"); // Displays dialog to inform the user the passwords were unequal and they must try // again AlertDialog.Builder builder = new AlertDialog.Builder(Register.this); builder .setMessage(R.string.androidIdAlertMessage) .setTitle(R.string.androidIdAlertTitle); builder.setCancelable( false); // Makes it so a user can't click outside of the alert to close the // dialog. They must click the button builder.setPositiveButton( "Back to Home", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // These two lines automatically take the user back to the home page after a // successful registration Intent goHome = new Intent(Register.this, HomePage.class); startActivity(goHome); } }); AlertDialog alert = builder.create(); alert.show(); } else { Log.d("No Match", "Android ID does not match any in table"); } } else { Log.d("score", "Error: " + e.getMessage()); } } }); }
public void discLoad() { // Acessa todos os dados de uma tabela ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Disciplina"); query.whereEqualTo("owner", ParseUser.getCurrentUser()); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> markers, ParseException e) { if (e == null) { for (ParseObject p : markers) { if (!p.getString("day_1").isEmpty()) { TextView t = listTextViewHour.get(p.getString("day_1")); String text = p.getString("hour_1") + " - " + p.getString("name") + " (" + p.getParseObject("course").getString("name") + ")\n"; t.append(text); } if (!p.getString("day_2").isEmpty()) { TextView t = listTextViewHour.get(p.getString("day_2")); String text = p.getString("hour_2") + " - " + p.getString("name") + " (" + p.getParseObject("course").getString("name") + ")\n"; t.append(text); } } for (int i = 0; i < listTextViewHour.size(); i++) { if (listTextViewHour.get(days[i]).getText().toString().isEmpty()) listTextViewHour .get(days[i]) .setText("Você não tem nenhuma disciplina neste dia!"); } } else { // handle Parse Exception here e.getCause(); } } }); }