Turkcell | Geleceği Yazanlar

null pointer exception hatası alıyorum

package com.example.proje;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

public class MainActivity extends AppCompatActivity  {
    EditText mTextaUsername;
    EditText mTextaPassword;
    Button mButtonLogin;
    Button mButtonRegister;

    FirebaseDatabase database;
  private    DatabaseReference ref;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        database = FirebaseDatabase.getInstance();
        ref=FirebaseDatabase.getInstance().getReference();

        mTextaUsername = (EditText) findViewById(R.id.txtuser);
        mTextaPassword = (EditText) findViewById(R.id.txtpass);
        mButtonLogin = (Button) findViewById(R.id.btnlog);
        mButtonRegister = (Button) findViewById(R.id.btnreg);
        mButtonRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent nt = new Intent(getApplicationContext(), Register.class);
                startActivity(nt);
            }
        });

       final   String name = mTextaUsername.getText().toString();
      final   String pass = mTextaPassword.getText().toString();


        mButtonLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                ref.child("kullanici").addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            for ( DataSnapshot postSnapshot:dataSnapshot.getChildren() ) {
                 kullanici kll = postSnapshot.getValue(kullanici.class);
                int uye = Log.d("UYE", kll.getAd());


             }

                            Toast.makeText(MainActivity.this, " oturum açıldı", Toast.LENGTH_SHORT).show();
                            Intent nt = new Intent(getApplicationContext(), homapage.class);
                            startActivity(nt);


                }

                    @Override
                    public void onCancelled(@NonNull DatabaseError databaseError) {

                    }
                });

            }
            });
    }

}


 

    0

    Burhan

    21 Eylül 2019

    Referansları ve initalize lerı kontrole diniz.

    Bu soruya cevap vermek için üye olmanız veya giriş yapmanız gerekmektedir.