I am writing an application for Android. I am too beginner. I copied and pasted a sample to my project. I want to make Authentication. But It gives me an exception of connection. I have created a firebase. I connect to my firebase server. But There is still one exception. I click to my button and result always return me. Same exception result. Here is my code, layout and images : enter image description here enter image description here My layout:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:layout_marginTop="10dp"
android:id="@+id/uyeEmail" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_marginTop="10dp"
android:id="@+id/uyeParola"
/>
<Button
android:text="Üye Ol!"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_marginTop="50dp"
android:id="@+id/yeniUyeButton"
/>
<Button
android:text="Zaten üye misin?"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/uyeGirisButton"
android:layout_marginBottom="10dp"
/>
My codes :
auth = FirebaseAuth.getInstance();
uyeParola = (EditText)findViewById(R.id.uyeParola);
uyeEmail = (EditText)findViewById(R.id.uyeEmail);
uyeGirisButton = (Button)findViewById(R.id.uyeGirisButton);
uyeGirisButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
yeniUyeButton = (Button)findViewById(R.id.yeniUyeButton);
yeniUyeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = uyeEmail.getText().toString();
String parola = uyeParola.getText().toString();
if(TextUtils.isEmpty(email)){
Toast.makeText(getApplicationContext(),"Lütfen emailinizi giriniz",Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(parola)){
Toast.makeText(getApplicationContext(),"Lütfen parolanızı giriniz",Toast.LENGTH_SHORT).show();
}
if (parola.length()<6){
Toast.makeText(getApplicationContext(),"Parola en az 6 haneli olmalıdır",Toast.LENGTH_SHORT).show();
}
//FirebaseAuth ile email,parola parametrelerini kullanarak yeni bir kullanıcı oluşturuyoruz.
auth.createUserWithEmailAndPassword(email,parola)
.addOnCompleteListener(giris.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
//İşlem başarısız olursa kullanıcıya bir Toast mesajıyla bildiriyoruz.
if (!task.isSuccessful()) {
Toast.makeText(giris.this, "Exception... Sorry :(",
Toast.LENGTH_SHORT).show();
}
//İşlem başarılı olduğu takdir de giriş yapılıp MainActivity e yönlendiriyoruz.
else {
startActivity(new Intent(giris.this, MainActivity.class));
finish();
}
}
});
}
});
My permission :
<uses-permission android:name="android.permission.INTERNET"></uses-permission>[enter image description here][1]