-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainActivity.java
More file actions
47 lines (37 loc) · 1.48 KB
/
MainActivity.java
File metadata and controls
47 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.example.root.ledcontrol;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.pusher.pushnotifications.PushNotifications;
public class MainActivity extends AppCompatActivity {
Button on;
Button off;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PushNotifications.start(getApplicationContext(), "61d2753d-9e78-4bc5-86d4-61e44fedab27");
PushNotifications.subscribe("hello");
on = (Button) findViewById(R.id.on);
off = (Button) findViewById(R.id.off);
on.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("LED_STATUS");
myRef.setValue(1);
}
});
off.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("LED_STATUS");
myRef.setValue(0);
}
});
}
}