{"id":764,"date":"2020-08-26T11:30:53","date_gmt":"2020-08-26T03:30:53","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=764"},"modified":"2021-09-14T11:19:11","modified_gmt":"2021-09-14T03:19:11","slug":"firebase-authentication","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/firebase-authentication\/","title":{"rendered":"Android Firebase Authentication"},"content":{"rendered":"<h1>Android Firebase Authentication<\/h1>\n<h5>\u4ecb\u7d39\u5982\u4f55\u900f\u904eFirebase\u9023\u7d50\u4f7f\u7528Authentication\u7684\u90e8\u5206\u4f86\u9032\u884c\u6703\u54e1\u8a8d\u8b49\u4ee5\u53ca\u6703\u54e1\u8a3b\u518a\uff0cFirebase Authentication\u5e6b\u52a9\u6211\u5011\u6c92\u6709\u6642\u9593\u8655\u7406\u5f8c\u7aef\u8ddf\u67b6\u8a2d\u4f3a\u670d\u5668\uff0c\u53ea\u9700\u8981\u5230Firebase\u4e3b\u63a7\u53f0\u5c31\u53ef\u4ee5\u8f15\u6613\u4f7f\u7528\u6703\u54e1\u76f8\u95dc\u8a3b\u518a\u7cfb\u7d71\uff0cAuthentication\u662f\u6700\u597d\u7684\u5e6b\u624b\u3002<\/h5>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u9304<\/h4>\n<ol>\n<li><a href=\"#a\">\u5c0e\u5165Firebase<\/a><\/li>\n<li><a href=\"#b\">\u9078\u53d6Authentication<\/a><\/li>\n<li><a href=\"#c\">\u9ede\u9078\u6309\u9215\u5f8c \u6253\u52fe\u9023\u7d50\u6210\u529f<\/a><\/li>\n<li><a href=\"#d\">\u7a0b\u5f0f\u78bc\u7bc4\u4f8b<\/a><\/li>\n<li><a href=\"#e\">\u6548\u679c\u5c55\u793a<\/a><\/li>\n<\/ol>\n<hr \/>\n<p><iframe loading=\"lazy\" title=\"\u3010Android\u3011Firebase Authentication | Kotlin | Android Studio\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/nO3Q0DqPzgE?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p><a id=\"a\"><\/a><\/p>\n<h4>1.\u5c0e\u5165Firebase<\/h4>\n<h5>Tools>Firebase<\/h5>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_695827b3c5fdb05d9915fe24a39534a0.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_695827b3c5fdb05d9915fe24a39534a0.jpg\" width=\"30%\"\/><\/a><\/p>\n<p><a id=\"b\"><\/a><\/p>\n<h4>2.\u9078\u53d6Authentication<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_0a9a3e1e27060bbce9c3daddc8489178.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_0a9a3e1e27060bbce9c3daddc8489178.jpg\" width=\"90%\"\/><\/a><\/p>\n<p><a id=\"c\"><\/a><\/p>\n<h4>3.\u9ede\u9078\u6309\u9215\u5f8c \u6253\u52fe\u9023\u7d50\u6210\u529f<\/h4>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_e3fdc14ee93dfc02027f96cd0df31644.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/wp_editor_md_e3fdc14ee93dfc02027f96cd0df31644.jpg\" width=\"90%\"\/><\/a><\/p>\n<p><a id=\"d\"><\/a><\/p>\n<h4>4.\u7a0b\u5f0f\u78bc\u7bc4\u4f8b<\/h4>\n<h5>Layout<\/h5>\n<pre><code class=\"language-XML line-numbers\">  &lt;EditText\n        android:id=\"@+id\/account\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"176dp\"\n        android:ems=\"10\"\n        android:inputType=\"textPersonName\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\" \/&gt;\n\n    &lt;EditText\n        android:id=\"@+id\/password\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"16dp\"\n        android:ems=\"10\"\n        android:inputType=\"textPersonName\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/account\" \/&gt;\n\n    &lt;Button\n        android:id=\"@+id\/register\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"40dp\"\n        android:layout_marginEnd=\"40dp\"\n        android:layout_marginRight=\"40dp\"\n        android:text=\"\u8a3b\u518a\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintHorizontal_bias=\"0.5\"\n        app:layout_constraintStart_toEndOf=\"@+id\/login\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/password\" \/&gt;\n\n    &lt;Button\n        android:id=\"@+id\/login\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginStart=\"40dp\"\n        android:layout_marginLeft=\"40dp\"\n        android:layout_marginTop=\"40dp\"\n        android:text=\"\u767b\u5165\"\n        app:layout_constraintEnd_toStartOf=\"@+id\/register\"\n        app:layout_constraintHorizontal_bias=\"0.5\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/password\" \/&gt;\n<\/code><\/pre>\n<h5>MainActivity.kt<\/h5>\n<pre><code class=\"language-Kotlin line-numbers\">register.setOnClickListener {\n      FirebaseAuth.getInstance().createUserWithEmailAndPassword(\n        account.text.toString(), password.text.toString()\n      ).addOnCompleteListener {\n          if (it.isSuccessful) {\n            Toast.makeText(this, \"\u5275\u5efa\u6210\u529f\", Toast.LENGTH_SHORT).show()\n          }\n      }\n}\n\nlogin.setOnClickListener {\n      FirebaseAuth.getInstance().signInWithEmailAndPassword(\n          account.text.toString(),password.text.toString()\n      ).addOnCompleteListener {\n          if (it.isSuccessful) {\n              Toast.makeText(this, \"\u767b\u5165\u6210\u529f\", Toast.LENGTH_SHORT).show()\n          }\n      }\n}\n<\/code><\/pre>\n<p><a id=\"e\"><\/a><\/p>\n<h4>5.\u6548\u679c\u5c55\u793a<\/h4>\n<h5>Firebase\u5f8c\u53f0\u986f\u793a<\/h5>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/1598412379389.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/1598412379389.jpg\" width=\"100%\"\/><\/a><\/p>\n<h5>APP\u986f\u793a<\/h5>\n<p><a href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/118439256_630128261030100_3445956013280130618_n.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/08\/118439256_630128261030100_3445956013280130618_n.jpg\" width=\"40%\"\/><\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Android Firebase Authentication \u4ecb\u7d39\u5982\u4f55\u900f\u904eFirebase\u9023\u7d50\u4f7f\u7528Authe &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[13,122,40],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-firebase","tag-android","tag-authentication","tag-firebase"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=764"}],"version-history":[{"count":8,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/764\/revisions"}],"predecessor-version":[{"id":1490,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/764\/revisions\/1490"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}