ProfileActivityGmail.java
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.example.user.firebaseauthdemo;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
/**
* Created by HYB on 2017. 10. 19..
*/
public class ProfileActivityGmail extends AppCompatActivity implements View.OnClickListener{
private FirebaseAuth firebaseAuth;
private TextView textViewGmail;
private Button buttonLogout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_simple_login);
firebaseAuth = FirebaseAuth.getInstance();
if(firebaseAuth.getCurrentUser() == null){
finish();
startActivity(new Intent(this,LoginActivity.class));
}
FirebaseUser user = firebaseAuth.getCurrentUser();
textViewGmail = (TextView) findViewById(R.id.textViewUserGmail);
textViewGmail.setText(" Welcome " + user.getEmail());
buttonLogout = (Button)findViewById(R.id.buttonLogout);
buttonLogout.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(view == buttonLogout) {
firebaseAuth.signOut();
finish();
startActivity(new Intent(this, LoginActivity.class));
}
}
}