Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Android中创建自定义对象并从任何活动访问它?_Java_Android_Firebase_Firebase Authentication - Fatal编程技术网

Java 如何在Android中创建自定义对象并从任何活动访问它?

Java 如何在Android中创建自定义对象并从任何活动访问它?,java,android,firebase,firebase-authentication,Java,Android,Firebase,Firebase Authentication,我已经创建了一个具有基本登录功能的基本Android应用程序。我想要执行的是,我已经创建了一个自定义对象updateUserUi- 公共类updateUserUI{ 字符串uid; 公共课锻炼{ 字符串标题; 字符串内容; } 公共类用户配置文件{ 私有字符串名称; 私人int DOB; 私人互联网; 私人字符串成员资格; 私人字符串训练器名称; } public void updateUserUI_方法(字符串uid){ this.uid=uid; FirebaseFirestore db=F

我已经创建了一个具有基本登录功能的基本Android应用程序。我想要执行的是,我已经创建了一个自定义对象updateUserUi-

公共类updateUserUI{
字符串uid;
公共课锻炼{
字符串标题;
字符串内容;
}
公共类用户配置文件{
私有字符串名称;
私人int DOB;
私人互联网;
私人字符串成员资格;
私人字符串训练器名称;
}
public void updateUserUI_方法(字符串uid){
this.uid=uid;
FirebaseFirestore db=FirebaseFirestore.getInstance();
最终updateUserUI=new updateUserUI();
db.集合(“用户”).文件(“Saheel”).集合(“档案”)
.document(“profile”).get().addOnSuccessListener(新OnSuccessListener()){
@凌驾
成功时公共无效(文档快照文档快照){
updateUserUI.userProfile userProfileZ=documentSnapshot.toObject(updateUserUI.userProfile.class);
}
});
}
}
在登录页面上,我将创建此类的对象,并使用Firebase返回的uid调用
updateUserUI\u方法(uid)

FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
如果(用户!=null){
字符串uid=user.getUid();
updateUserUI updateUserUIMain=新的updateUserUI();
updateUserUIMain.updateUserUI_方法(uid);
}否则{
//没有用户登录
}
在这个方法下,我将把所有的概要文件文档数据检索到它的概要文件嵌套对象
userProfileZ
,其余的都一样


db.集合(“用户”).文件(“Saheel”).集合(“档案”)
.document(“profile”).get().addOnSuccessListener(新OnSuccessListener()){
@凌驾
成功时公共无效(文档快照文档快照){
updateUserUI.userProfile userProfileZ=documentSnapshot.toObject(updateUserUI.userProfile.class);
}
});
现在在profile活动中,我想直接访问
updateUserUIMain
对象并更新该布局的UI组件。但是我无法访问对象,使用oops概念执行此方法或任何其他方法从Firebase获取数据的正确方式是什么