package com.tutkugurur.realchat; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.view.inputmethod.InputConnectionCompat; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.annotations.NotNull; public class GirisActivity extends AppCompatActivity { EditText kullaniciAdiEditText; Button kayitOlButton; FirebaseDatabase firebaseDatabase; DatabaseReference reference; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_giris); tanimla(); } public void tanimla() { kullaniciAdiEditText = (EditText) findViewById(R.id.kullaniciEditText); kayitOlButton = (Button) findViewById(R.id.kayitOlButton); firebaseDatabase = FirebaseDatabase.getInstance(); reference = firebaseDatabase.getReference(); kayitOlButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = kullaniciAdiEditText.getText().toString(); kullaniciAdiEditText.setText(""); ekle(username); } public void ekle(String kadi) { { reference.child("Kullanıcılar").child(kadi).child("kullanicidiadi").setValue(kadi).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { Toast.makeText(getApplicationContext(), "Başarı ile Kayıt Oldunuz", Toast.LENGTH_LONG).show() } } }) } } } ) } }