This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Hello World</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
alert("Hello World!") | |
// single line Comment | |
<!-- This is a | |
multi line comment --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.firebasegoogleauth | |
import android.content.Intent | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import com.bumptech.glide.Glide | |
import com.google.firebase.auth.FirebaseAuth | |
import kotlinx.android.synthetic.main.activity_dashboard.* | |
class DashboardActivity : AppCompatActivity() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".DashboardActivity"> | |
<ImageView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
classpath "com.android.tools.build:gradle:4.0.2" | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
classpath 'com.google.gms:google-services:4.3.4' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun firebaseAuthWithGoogle(idToken: String) { | |
val credential = GoogleAuthProvider.getCredential(idToken, null) | |
mAuth.signInWithCredential(credential) | |
.addOnCompleteListener(this) { task -> | |
if (task.isSuccessful) { | |
// Sign in success, update UI with the signed-in user's information | |
Log.d("SignInActivity", "signInWithCredential:success") | |
val intent = Intent(this, DashboardActivity::class.java) | |
startActivity(intent) | |
finish() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if( requestCode == RC_SIGN_IN){ | |
val task = GoogleSignIn.getSignedInAccountFromIntent(data) | |
val exception = task.exception | |
if (task.isSuccessful){ | |
try { | |
// Google Sign In was successful, authenticate with Firebase | |
val account = task.getResult(ApiException::class.java)!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onStart() { | |
super.onStart() | |
val currentUser = mAuth!!.currentUser | |
if (currentUser != null){ | |
val dashboardIntent = Intent(this, DashboardActivity::class.java) | |
startActivity(dashboardIntent) | |
finish() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sign_in_google.setOnClickListener { | |
val signInIntent = mGoogleSignInClient.signInIntent | |
startActivityForResult(signInIntent, RC_SIGN_IN) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//requesting user ID, email address, and | |
// basic profile are included in DEFAULT_SIGN_IN. | |
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) | |
.requestIdToken(getString(R.string.client_id)) | |
.requestEmail() | |
.build() | |
// Build a GoogleSignInClient with the options specified by gso. | |
mGoogleSignInClient = GoogleSignIn.getClient(this,gso) | |
//google sign-in button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.firebasegoogleauth | |
import android.content.Intent | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.google.android.gms.auth.api.signin.GoogleSignIn | |
import com.google.android.gms.auth.api.signin.GoogleSignInClient | |
import com.google.android.gms.auth.api.signin.GoogleSignInOptions | |
import com.google.android.gms.common.SignInButton |
NewerOlder