无法访问存储在Firebase数据库中的图片网址

时间:2016-11-16 18:03:11

标签: java firebase-realtime-database

这是我的数据库快照DatabaseSnapshot。我正在向用户注册他/她的个人资料图片。我希望当该特定注册用户登录应用时,他应该能够在此Splash活动中访问他/她的图像class。问题是当用户注册自己时如何访问数据库生成的唯一id。

Splash.java

public class Splash extends Register {
private DatabaseReference reference;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    imageView = (ImageView) findViewById(R.id.imageView2);
reference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://lpuevents-8f661.firebaseio.com/AppUsers");

   // DatabaseReference reference = userInfo.child(postId).child("image");
    reference.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Picasso.with(getBaseContext()).load(dataSnapshot.toString()).into(imageView);
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

    /****** Create Thread that will sleep for 5 seconds *************/
    Thread background = new Thread() {
        public void run() {

            try {
                // Thread will sleep for 5 seconds
                sleep(5*1000);

                // After 5 seconds redirect to another intent
                Intent i=new Intent(Splash.this,HomePage.class);
                startActivity(i);

                //Remove activity
                finish();

            } catch (Exception e) {

            }
        }
    };

    // start thread
    background.start();
}
}

0 个答案:

没有答案