Issue
how we can pass uid of current user login from adapter to other activity I am already passing the clicked item id from adapter to other activity that easy because I already print this id but I am confused about how to pass the uid of current user login please guide
//I have retrieve data in main activity of current user
private void loadmyinfo() {
DatabaseReference ref= FirebaseDatabase.getInstance().getReference("Users");
ref .orderByChild("uid").equalTo(firebaseAuth.getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
for(DataSnapshot ds:snapshot.getChildren())
{
String Nam=""+ds.child("name").getValue();
// String accounttype=""+ds.child("account type").getValue();
String Profile=""+ds.child("profileuser").getValue();
String Email=""+ds.child("email").getValue();
String cphone=""+ds.child("phone").getValue();
nametx.setText(Nam);
cphon.setText(cphone);
nameemail.setText(Email);
try {
/* Glide.with(ProfileeditsellerActivity.this)
.load(Profile)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(profile);*/
Picasso.get().load(Profile).placeholder(R.drawable.ic_profile_gray).into(profile);
}
catch (Exception e){
profile.setImageResource(R.drawable.ic_profile_gray);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
adapter class
//In adapter class I have passed the id of clicked item but I want also to pass uid of current user
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* Intent intent=new Intent(context,BilActivity.class);
intent.putExtra("id",id);
context.startActivity(intent);*/
Intent intent=new Intent(holder.itemView.getContext(),PayfeeActivity.class);
intent.putExtra("id",id);
holder.itemView.getContext().startActivity(intent);
}
});
Solution
you can get the current logged in firebase user from anywhere in your app using
FirebaseAuth.getInstance().getCurrentUser().getUid();
Answered By - huda Olayan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.