Created
November 7, 2017 19:57
-
-
Save yakutozcan/e9da84dd34327fe97962e4dc4728e7fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package haydut.firebaseled; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import com.google.firebase.database.DatabaseReference; | |
import com.google.firebase.database.FirebaseDatabase; | |
public class MainActivity extends AppCompatActivity { | |
int i = 2; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Button BTNLed = (Button)findViewById(R.id.button3); | |
//Firebase bağlantısını yapıyoruz | |
FirebaseDatabase database = FirebaseDatabase.getInstance(); | |
//LedStatus alanına işlem yapacağız | |
final DatabaseReference myRef = database.getReference("LEDStatus"); | |
BTNLed.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
if(i%2==0){ | |
//i çift ise 1 yaz | |
myRef.setValue(1); | |
}else{ | |
//i tek ise 0 yaz | |
myRef.setValue(0); | |
} | |
i++; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment