Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-005
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-005
2022-005
Commits
761c2704
Commit
761c2704
authored
Oct 10, 2022
by
Chathura IT19243986
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
14bd38b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
signin.java
signin.java
+85
-0
No files found.
signin.java
0 → 100644
View file @
761c2704
package
com.example.peopluz1
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Patterns
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.Toast
;
import
com.google.android.gms.tasks.OnCompleteListener
;
import
com.google.android.gms.tasks.Task
;
import
com.google.firebase.auth.AuthResult
;
import
com.google.firebase.auth.FirebaseAuth
;
public
class
signin
extends
AppCompatActivity
{
private
Button
login
;
EditText
mEmail
,
mPassword
;
FirebaseAuth
fAuth
;
String
userID
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_signin
);
fAuth
=
FirebaseAuth
.
getInstance
();
login
=
findViewById
(
R
.
id
.
btnlogin
);
mEmail
=
findViewById
(
R
.
id
.
email
);
mPassword
=
findViewById
(
R
.
id
.
pass
);
if
(
fAuth
.
getCurrentUser
()
!=
null
){
startActivity
(
new
Intent
(
getApplicationContext
(),
home
.
class
));
finish
();
}
login
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
email
=
mEmail
.
getText
().
toString
().
trim
();
String
password
=
mPassword
.
getText
().
toString
().
trim
();
if
(
TextUtils
.
isEmpty
(
email
)
||
!
Patterns
.
EMAIL_ADDRESS
.
matcher
(
email
).
matches
()){
mEmail
.
setError
(
"Email is Required."
);
return
;
}
if
(
TextUtils
.
isEmpty
(
password
)){
mPassword
.
setError
(
"Password is Required."
);
return
;
}
if
(
password
.
length
()
<
6
){
mPassword
.
setError
(
"Password Must be >= 6 Characters"
);
return
;
}
fAuth
.
signInWithEmailAndPassword
(
email
,
password
).
addOnCompleteListener
(
new
OnCompleteListener
<
AuthResult
>()
{
@Override
public
void
onComplete
(
@NonNull
Task
<
AuthResult
>
task
)
{
if
(
task
.
isSuccessful
()){
Toast
.
makeText
(
signin
.
this
,
"Logged in Successfully"
,
Toast
.
LENGTH_SHORT
).
show
();
startActivity
(
new
Intent
(
getApplicationContext
(),
home
.
class
));
}
else
{
Toast
.
makeText
(
signin
.
this
,
"Error ! "
+
task
.
getException
().
getMessage
(),
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
// Intent intent = new Intent(signin.this,home.class);
// startActivity(intent);
// finish();
}
});
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment