第24天~Firebase

Firebase是Firebase, Inc.在2011年发布的行动和网路应用程序开发者平台,在2014年被Google收购。 截至2020年3月,Firebase平台拥有19项产品,它们被超过150万个应用程序采用。

https://firebase.google.com/

新增专案
https://ithelp.ithome.com.tw/upload/images/20220204/201190357zPbyBQxrE.png

近来到这里

https://ithelp.ithome.com.tw/upload/images/20220204/20119035UejGkVPZl4.png

新增专案
https://ithelp.ithome.com.tw/upload/images/20220204/201190355LCjJ8J2Vg.png


到XML档 也是要绑onClick

https://ithelp.ithome.com.tw/upload/images/20220204/20119035FZtydVmOvF.png

<?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=".MainActivity">

    <EditText
        android:id="@+id/editText"
        android:layout_width="267dp"
        android:layout_height="70dp"
        android:layout_marginTop="76dp"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="input"
        android:textAppearance="@style/TextAppearance.AppCompat.Large"
        android:textSize="30sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.422"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="60dp"
        android:onClick="onClick"
        android:text="送出"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.432"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editText" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="124dp"
        android:onClick="onClick"
        android:text="删除"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.432"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="144dp"
        android:onClick="onClick"
        android:text="更新"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.432"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button2" />
</androidx.constraintlayout.widget.ConstraintLayout>

onClick完到JAVA档

https://ithelp.ithome.com.tw/upload/images/20220204/201190351mX3oYzGWm.png

package com.huang.myfirebase01;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onClick(View view) {
    }
}

找到Firebase

https://ithelp.ithome.com.tw/upload/images/20220204/201190350FMVSOguyd.png

看到右边

https://ithelp.ithome.com.tw/upload/images/20220204/20119035rYJZKjHTqu.png
点蓝色字

https://ithelp.ithome.com.tw/upload/images/20220204/201190353u9DehQ1iH.png

要先新增之後再点
https://ithelp.ithome.com.tw/upload/images/20220204/20119035ebrpjwXQJV.png

会发生连结

https://ithelp.ithome.com.tw/upload/images/20220204/20119035zct2xwdB66.png

要看到的画面

https://ithelp.ithome.com.tw/upload/images/20220204/20119035G5IJ2JSUvb.png

可以关掉
回到ANDROID会看到
https://ithelp.ithome.com.tw/upload/images/20220204/20119035PpihFSp8Fv.png

再来点第2个
https://ithelp.ithome.com.tw/upload/images/20220204/20119035tsyoWeKOER.png

出现的画面按"同意"-->让经度条跑完
https://ithelp.ithome.com.tw/upload/images/20220204/20119035PAt0QmUrg3.png

第3步到网站-规则
https://ithelp.ithome.com.tw/upload/images/20220204/20119035sIJCLh6KTW.png

原来是-false
https://ithelp.ithome.com.tw/upload/images/20220204/20119035WafvLDeCKk.png

要改成 true就是任何人何时都可以改

https://ithelp.ithome.com.tw/upload/images/20220204/20119035nG7hay6Mz4.png

https://ithelp.ithome.com.tw/upload/images/20220204/20119035vlKywYlIwQ.png


回到ANDROID可以看到Gradle Scripts的build.gradle已经新增Firebase

https://ithelp.ithome.com.tw/upload/images/20220204/20119035yj7wmp0Ndl.png

再到Project的 app的google-services.json可以看到自己的Firebase名称

https://ithelp.ithome.com.tw/upload/images/20220204/20119035QCXGBOYbjA.png

把旁边的第4步贴上~然後开始改"反红"

https://ithelp.ithome.com.tw/upload/images/20220204/20119035B4wN2wI5B0.png

通通都先ALT+ENTER 让"反红"不见

https://ithelp.ithome.com.tw/upload/images/20220204/20119035B2zoFikfKJ.png

// Write a message to the database
        FirebaseDatabase database = FirebaseDatabase.getInstance();//产生资料
        DatabaseReference myRef = database.getReference("message");//产生参考节点

        myRef.setValue("Hello, World!");

然後按RUN

到Firebase网站看-

https://ithelp.ithome.com.tw/upload/images/20220204/20119035ydccWtHHv6.png

连上了~
https://ithelp.ithome.com.tw/upload/images/20220204/20119035STM88BRfq1.png

换看看message的字

// Write a message to the database
        FirebaseDatabase database = FirebaseDatabase.getInstance();//产生资料
        DatabaseReference myRef = database.getReference("message");//产生参考节点

        myRef.setValue("Hello, World!");

https://ithelp.ithome.com.tw/upload/images/20220204/20119035v4PY9zGclS.png

到Firebase网站
https://ithelp.ithome.com.tw/upload/images/20220204/20119035UjGUFaklFv.png

换看看Hello, World!的字

https://ithelp.ithome.com.tw/upload/images/20220204/20119035weFd9bDwEt.png

到Firebase网站

https://ithelp.ithome.com.tw/upload/images/20220204/20119035S094ElAhAl.png

连线完成~
可以看的Firebase网站说明

https://firebase.google.com/docs/android/setup?authuser=0


今天是连假的第一天~祝大家双十节快乐
五倍卷也发了~好小0.0

因为下礼拜要面试的关系~所以一直在看C#发现其实Microsoft Visuall Studio的使用英文说明
跟Android很像~所以我的纯文字说明是有用的^^

後面应该会有图案了~现在先来纯文字:

  1. 要横的排要放入Layouts->要记得绑定
  2. 放checkBox->Layouts不好调-按纽和字都会跑入~要靠移动旁边的tree(这个真的是小秘诀)
  3. 有时候或许调程序码还比较快(虽然调看的到的东西比较有感觉)
  4. 要GROUP去管理...所以要有ID
  5. 如果text不能改就要从CODE去改(虽然调看的到的东西比较有感觉)
  6. 到onClick的orientation可以看到变横的horizontal
  7. 让linerlayout跟着副容器的大小
    在Declared Attributs里layout_wiudth和match_wiudth 选wrap_content或0dp
    8.然後让边边有留边要选到padding(这个在有打CSS的CODE也是)
    9.Button-onCilck可以动做
    10.显示字串:String all=””;
    就是显示有人打的东西

希望...可以让我继续有铁人发文的机会~拜托拜托


<<:  Day25-React 效能优化篇-下篇(介绍 React Profiler)

>>:  Day24-你的资料安全吗(二)

Microsoft Azure Machine Learning - Day 3

Chap.I Practical drill 实战演练 以下内容来自这里 Prat4. Run Ex...

Day 02 - 行前说明 — 网页微切版架构 和 UI 元件

作为正式开始的第一篇要来讲的是很基础的网页切版和怎麽去看网页中有哪些元件,会分两部分: 网页微切版...

Kneron - Kneron Toolchain 转档操作参考笔记

Kneron - Kneron Toolchain 转档操作参考笔记 参考资料 onnx 档案来源:...

Day27-JDK可视化监控工具:visualVM(三)

前言 延续着上篇的介绍,这篇要来介绍visualVM的Monitor页签 Monitor Uptim...

JavaScript Callback(回呼)

Callback Function 回呼函数 A function you give to anot...