Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final Button checkButton = (Button) findViewById(R.id.checkBtn);
- checkButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mDatabase.child("users").child(mUserId).child("barcodes").orderByChild("content")
- .equalTo(contentTxt.toString()).addListenerForSingleValueEvent(new ValueEventListener(){
- @Override
- public void onDataChange(DataSnapshot dataSnapshot) {
- if (dataSnapshot.hasChildren()){
- // method that alters update text TextBox
- set_alarm_text("Alarm off!");
- // cancel the alarm
- alarm_manager.cancel(pending_intent);
- // put in extra string into my_intent, telling the clock that "Alarm Off" was pressed
- my_intent.putExtra("extra", "alarm off");
- // stop the ringtone
- sendBroadcast(my_intent);
- }
- else{
- Toast toast = Toast.makeText(getApplicationContext(),
- "This is not a scanned barcode!", Toast.LENGTH_SHORT);
- toast.show();
- }
- }
- @Override
- public void onCancelled(DatabaseError databaseError) {
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement