Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. final Button checkButton = (Button) findViewById(R.id.checkBtn);
  2. checkButton.setOnClickListener(new OnClickListener() {
  3. @Override
  4. public void onClick(View v) {
  5. mDatabase.child("users").child(mUserId).child("barcodes").orderByChild("content")
  6. .equalTo(contentTxt.toString()).addListenerForSingleValueEvent(new ValueEventListener(){
  7. @Override
  8. public void onDataChange(DataSnapshot dataSnapshot) {
  9. if (dataSnapshot.hasChildren()){
  10. // method that alters update text TextBox
  11. set_alarm_text("Alarm off!");
  12.  
  13. // cancel the alarm
  14. alarm_manager.cancel(pending_intent);
  15.  
  16. // put in extra string into my_intent, telling the clock that "Alarm Off" was pressed
  17. my_intent.putExtra("extra", "alarm off");
  18.  
  19. // stop the ringtone
  20. sendBroadcast(my_intent);
  21. }
  22. else{
  23. Toast toast = Toast.makeText(getApplicationContext(),
  24. "This is not a scanned barcode!", Toast.LENGTH_SHORT);
  25. toast.show();
  26. }
  27. }
  28. @Override
  29. public void onCancelled(DatabaseError databaseError) {
  30.  
  31. }
  32. });
  33. }
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement