にnull値を返しています。 appフォルダ内のJSONが、私はコードをデバッグするときに(ユーザーが)FirebaseUser user = firebaseAuth.getCurrentUser();
.MYコードは以下の通りであるnull値を示しています。成功した後なぜFirebaseAuth.getInstance()。GETCURRENTUSERは()私は私がfirebaseストレージURL、データベースURL、データベースルール(真)、sha1を置くグーグル・サービスを設定している<a href="https://github.com/sancarbar/firebase-android." rel="nofollow noreferrer">Code for sending images using firebase</a></p> <p>次い
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import butterknife.Bind;
import butterknife.ButterKnife;
public class LoginActivity
extends AppCompatActivity
implements FirebaseAuth.AuthStateListener
{
@Bind(R.id.login_button)
Button loginButton;
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
}
@Override
public void onStart()
{
super.onStart();
firebaseAuth.addAuthStateListener(this);
verifyCurrentUserAndStartMainActivityIfLoggedIn();
}
@Override
public void onStop()
{
super.onStop();
firebaseAuth.removeAuthStateListener(this);
}
public void onLoginClicked(View view)
{
loginButton.setEnabled(false);
firebaseAuth.signInAnonymously();
}
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth)
{
verifyCurrentUserAndStartMainActivityIfLoggedIn();
}
private void verifyCurrentUserAndStartMainActivityIfLoggedIn()
{
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) //HERE I AM GETTING "user=null" ??
{
startActivity(new Intent(this, MainActivity.class));
Toast.makeText(this,"Login success",Toast.LENGTH_LONG).show();
finish();
}
else
{
loginButton.setEnabled(true);
}
}
}
(!ユーザー= null)のログイン今すぐ次のアクティビティを表示次の活動のサンプルURLは
ですfirebaseで// StorageReference storageRef = storage.getReferenceFromUrl("gs://funchat-ef3ed.appspot.com");
、私が作成した新しいストレージを取得するURLは次のとおりです。
StorageReference storageRef = storage.getReferenceFromUrl("gs://fir-imagesending-1a8c1.appspot.com");
私は、URLのアプリケーションがクラッシュした上で使用します。コードは次のとおりです。
public class MainActivity extends AppCompatActivity
{
static final int REQUEST_IMAGE_CAPTURE = 1;
FirebaseDatabase database = FirebaseDatabase.getInstance();
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
DatabaseReference databaseReference = database.getReference("messages");
FirebaseStorage storage = FirebaseStorage.getInstance();
// StorageReference storageRef = storage.getReferenceFromUrl("gs://funchat-ef3ed.appspot.com");
StorageReference storageRef = storage.getReferenceFromUrl("gs://fir-imagesending-1a8c1.appspot.com");
私は行方不明を見つけることができません。
firebase consoleで匿名ログインを有効にしましたか? – VizGhar
もしあれば、 'signInAnonymously()。addOnCompleteListener ...'を使ってコールバックのエラーを確認してください。 – VizGhar
@VizGhar Fireベースからの匿名ログインを有効にしました。 –