SlideShare a Scribd company logo
1 of 85
Download to read offline
Firebase with
Android
GCPUG TOKYO MARCH 2016
Firebase
Firebase
• Realtime Database
• Authentication & Access Control
• Static Web Site Hosting
Udacity
• Firebase Essential For Android
• https://www.udacity.com/course/firebase-
essentials-for-android--ud009
Getting Started
www.firebase.com
dependencies {
compile 'com.firebase:firebase-client-android:2.5.2+'
}
android {
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
<uses-permission android:name="android.permission.INTERNET" />
Custom Application
public class MyApplication extends Application {

@Override

public void onCreate() {

super.onCreate();

Firebase.setAndroidContext(this);

}

}
AndroidManifest.xml
<application

android:name=".MyApplication"

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:supportsRtl="true"

android:theme="@style/AppTheme">
Writing Data
AndroidManifest.xml
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").setValue("hello firebase!");
Activity
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").setValue("hello firebase!");
Reference
Activity
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").setValue("hello firebase!");
Child Node
Activity
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").setValue("hello firebase!");
Writing
Not Limited to
Primitive Types
public class BlogPost {
private String author;
private String title;
public BlogPost() {
// empty default constructor
// necessary for Firebase to be able to deserialize blog posts
}
public String getAuthor() {
return author;
}
public String getTitle() {
return title;
}
}
Understating
Data Structure
NoSQL JSON Tree
{
"users": {
"mchen": {
"friends": { "brinchen": true },
"name": "Mary Chen",
// our child node appears in the existing JSON tree
"widgets": { "one": true, "three": true }
},
"brinchen": { ... },
"hmadi": { ... }
}
}
NoSQL JSON Tree
{
"users": {
"mchen": {
"friends": { "brinchen": true },
"name": "Mary Chen",
// our child node appears in the existing JSON tree
"widgets": { "one": true, "three": true }
},
"brinchen": { ... },
"hmadi": { ... }
}
}
NoSQL JSON Tree
{
"users": {
"mchen": {
"friends": { "brinchen": true },
"name": "Mary Chen",
// our child node appears in the existing JSON tree
"widgets": { "one": true, "three": true }
},
"brinchen": { ... },
"hmadi": { ... }
}
}
/users/mchen/widgets
NoSQL JSON Tree
{
"users": {
"mchen": {
"friends": { "brinchen": true },
"name": "Mary Chen",
// our child node appears in the existing JSON tree
"widgets": { "one": true, "three": true }
},
"brinchen": { ... },
"hmadi": { ... }
}
}
/users/mchen/widgets
Unique Identifier
Valid Types
• String
• Boolean
• Long
• Double
• Map<String, Object>
• List<Object>
Retrieving Data
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

Toast.makeText(
MainActivity.this,
dataSnapshot.getValue(String.class),
Toast.LENGTH_SHORT
).show();

}



@Override

public void onCancelled(FirebaseError firebaseError) {



}

});
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

Toast.makeText(
MainActivity.this,
dataSnapshot.getValue(String.class),
Toast.LENGTH_SHORT
).show();

}



@Override

public void onCancelled(FirebaseError firebaseError) {



}

});
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

Toast.makeText(
MainActivity.this,
dataSnapshot.getValue(String.class),
Toast.LENGTH_SHORT
).show();

}



@Override

public void onCancelled(FirebaseError firebaseError) {



}

});
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

Toast.makeText(
MainActivity.this,
dataSnapshot.getValue(String.class),
Toast.LENGTH_SHORT
).show();

}



@Override

public void onCancelled(FirebaseError firebaseError) {



}

});
Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");

firebaseRef.child("message").addValueEventListener(new ValueEventListener() {

@Override

public void onDataChange(DataSnapshot dataSnapshot) {

Toast.makeText(
MainActivity.this,
dataSnapshot.getValue(String.class),
Toast.LENGTH_SHORT
).show();

}



@Override

public void onCancelled(FirebaseError firebaseError) {



}

});
Read Event Types
• Value
• Child Added
• Child Changed
• Child Removed
• Child Moved
Value Event
• ValueEventListener#onDataChange
• Retrieve whole data at once
• Called once at initial time, then every time
data changes.
// Get a reference to our posts
Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
// Attach an listener to read the data at our posts reference
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("There are " + snapshot.getChildrenCount() + " blog posts");
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
BlogPost post = postSnapshot.getValue(BlogPost.class);
System.out.println(post.getAuthor() + " - " + post.getTitle());
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
// Get a reference to our posts
Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
// Attach an listener to read the data at our posts reference
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("There are " + snapshot.getChildrenCount() + " blog posts");
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
BlogPost post = postSnapshot.getValue(BlogPost.class);
System.out.println(post.getAuthor() + " - " + post.getTitle());
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
// Get a reference to our posts
Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
// Attach an listener to read the data at our posts reference
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
System.out.println("There are " + snapshot.getChildrenCount() + " blog posts");
for (DataSnapshot postSnapshot: snapshot.getChildren()) {
BlogPost post = postSnapshot.getValue(BlogPost.class);
System.out.println(post.getAuthor() + " - " + post.getTitle());
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
Child Added Event
• ChildEventListener#onChildAdded
• Once for each existing child initially
• Every time new data is added
// Get a reference to our posts
Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
ref.addChildEventListener(new ChildEventListener() {
// Retrieve new posts as they are added to the database
@Override
public void onChildAdded(DataSnapshot snapshot, String previousChildKey) {
BlogPost newPost = snapshot.getValue(BlogPost.class);
System.out.println("Author: " + newPost.getAuthor());
System.out.println("Title: " + newPost.getTitle());
}
//... ChildEventListener also defines onChildChanged, onChildRemoved,
// onChildMoved and onCanceled, covered in later sections.
});
Child Changed Event
• ChildEventListener#onChildChanged
• Anytime a child is changed including its
descendants
@Override
public void onChildChanged(DataSnapshot snapshot, String previousChildKey) {
String title = (String) snapshot.child("title").getValue();
System.out.println("The updated post title is " + title);
}
Child Removed Event
• ChildEventListener#onChildRemoved
• Anytime a child is removed
@Override
public void onChildRemoved(DataSnapshot snapshot) {
String title = (String) snapshot.child("title").getValue();
System.out.println("The blog post titled " + title + " has been deleted");
}
Child Moved Event
• ChildEventListener#onChildMoved
• Anytime a child is moved
@Override
public void onChildMoved(DataSnapshot snapshot, String previousChildKey) {
String title = (String) snapshot.child("title").getValue();
System.out.println("The updated post title is " + title);
}
Detaching Callbacks
• ref.removeEventListener(originalListener);
• all listeners must be removed explicitly
• removing parent listener will NOT remove
child's listeners
Reading Data Once
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
// do some stuff once
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
// do some stuff once
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
Querying Data
{
"lambeosaurus": {
"height" : 2.1,
"length" : 12.5,
"weight": 5000
},
"stegosaurus": {
"height" : 4,
"length" : 9,
"weight" : 2500
}
}
public class DinosaurFacts {
long height;
double length;
long weight;
public DinosaurFacts() {
// empty default constructor
// necessary for Firebase to be able to deserialize blog posts
}
public long getHeight() {
return height;
}
public double getLength() {
return length;
}
public long getWeight() {
return weight;
}
}
• orderByChild()
• orderByKey()
• orderByValue()
• orderByPriority()
orderByChild
Query queryRef = ref.orderByChild("height");
or
Query queryRef = ref.orderByChild("dimensions/height");
orderByKey
Query queryRef = ref.orderByKey();
{
"lambeosaurus": {
"height" : 2.1,
"length" : 12.5,
"weight": 5000
},
"stegosaurus": {
"height" : 4,
"length" : 9,
"weight" : 2500
}
}
orderByValue
Query queryRef = ref.orderByValue();
{
"scores": {
"bruhathkayosaurus" : 55,
"lambeosaurus" : 21,
"linhenykus" : 80,
"pterodactyl" : 93,
"stegosaurus" : 5,
"triceratops" : 22
}
}
orderByPriority
Query queryRef = ref.orderByPriority();
orderByPriority
Query queryRef = ref.orderByPriority();
arbitrary priority you set
• limitToFirst()
• limitToLast()
• startAt()
• endAt()
• equalTo()
Query queryRef = ref.orderByChild("height").limitToFirst(2);
Query queryRef = scoresRef.orderByValue().limitToLast(3);
Query queryRef = ref.orderByChild("height").startAt(3);
Query queryRef = ref.orderByKey().endAt("pterodactyl");
Query queryRef = ref.orderByChild("height").equalTo(25);
Security
{
"rules": {
"users": {
"$user_id": {
".write": "$user_id === auth.uid"
}
}
}
}
{
"rules": {
"users": {
"$user_id": {
".write": "$user_id === auth.uid"
}
}
}
}
{
"rules": {
"users": {
"$user_id": {
".write": "$user_id === auth.uid"
}
}
}
} talks about this later
Authentication
Custom
• helper libraries to integrate with your own
authentications
• https://www.firebase.com/docs/android/
guide/login/custom.html#section-rest-token-
helper-libraries
Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/");
ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticationError(FirebaseError error) {
System.err.println("Login Failed! " + error.getMessage());
}
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("Login Succeeded!");
}
});
Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/");
ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticationError(FirebaseError error) {
System.err.println("Login Failed! " + error.getMessage());
}
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("Login Succeeded!");
}
});
Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/");
ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticationError(FirebaseError error) {
System.err.println("Login Failed! " + error.getMessage());
}
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("Login Succeeded!");
}
});
given from your server
Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/");
ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() {
@Override
public void onAuthenticationError(FirebaseError error) {
System.err.println("Login Failed! " + error.getMessage());
}
@Override
public void onAuthenticated(AuthData authData) {
System.out.println("Login Succeeded!");
}
});
• javadoc
• https://www.firebase.com/docs/java-api/
javadoc/com/firebase/client/AuthData.html
• AuthData#getUid()
Unique Guaranteed
Tips
• SwipeRefresh should be used with
ValueEvent(once)
Limitations
• No File Uploading APIs
• Server side batching
• Server side scheduling
• Server side event hook
Q & A
Samples
• Chat
• https://github.com/firebase/AndroidChat
• Drawing
• https://github.com/firebase/AndroidDrawing
THX!

More Related Content

What's hot

Containerizing ContentBox CMS
Containerizing ContentBox CMSContainerizing ContentBox CMS
Containerizing ContentBox CMSGavin Pickin
 
12 Ways to Supercharge Your Connect Add-on
12 Ways to Supercharge Your Connect Add-on12 Ways to Supercharge Your Connect Add-on
12 Ways to Supercharge Your Connect Add-onAtlassian
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020Matt Raible
 
Integration Testing on Steroids: Run Your Tests on the Real Things
Integration Testing on Steroids: Run Your Tests on the Real ThingsIntegration Testing on Steroids: Run Your Tests on the Real Things
Integration Testing on Steroids: Run Your Tests on the Real ThingsAtlassian
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Matt Raible
 
What's New with Confluence Connect
What's New with Confluence ConnectWhat's New with Confluence Connect
What's New with Confluence ConnectAtlassian
 
Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Matt Raible
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugToshiaki Maki
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastAtlassian
 
Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017Matt Raible
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
From Spring Boot 2.2 to Spring Boot 2.3 #jsugFrom Spring Boot 2.2 to Spring Boot 2.3 #jsug
From Spring Boot 2.2 to Spring Boot 2.3 #jsugToshiaki Maki
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3Zachary Klein
 
Angular 4 with firebase
Angular 4 with firebaseAngular 4 with firebase
Angular 4 with firebaseAnne Bougie
 
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache TomcatCase Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache TomcatVMware Hyperic
 
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020AWSKRUG - AWS한국사용자모임
 
Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017Matt Raible
 
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜崇之 清水
 
Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017VMware Tanzu Korea
 

What's hot (20)

Containerizing ContentBox CMS
Containerizing ContentBox CMSContainerizing ContentBox CMS
Containerizing ContentBox CMS
 
12 Ways to Supercharge Your Connect Add-on
12 Ways to Supercharge Your Connect Add-on12 Ways to Supercharge Your Connect Add-on
12 Ways to Supercharge Your Connect Add-on
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
Integration Testing on Steroids: Run Your Tests on the Real Things
Integration Testing on Steroids: Run Your Tests on the Real ThingsIntegration Testing on Steroids: Run Your Tests on the Real Things
Integration Testing on Steroids: Run Your Tests on the Real Things
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
 
What's New with Confluence Connect
What's New with Confluence ConnectWhat's New with Confluence Connect
What's New with Confluence Connect
 
Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021Web App Security for Java Developers - UberConf 2021
Web App Security for Java Developers - UberConf 2021
 
Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 
Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017Bootiful Development with Spring Boot and React - SpringOne 2017
Bootiful Development with Spring Boot and React - SpringOne 2017
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
From Spring Boot 2.2 to Spring Boot 2.3 #jsugFrom Spring Boot 2.2 to Spring Boot 2.3 #jsug
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3
 
Angular 4 with firebase
Angular 4 with firebaseAngular 4 with firebase
Angular 4 with firebase
 
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache TomcatCase Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
Case Study: Migrating Hyperic from EJB to Spring from JBoss to Apache Tomcat
 
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
Amplify를 통해 클라우드 기반 모바일 앱 개발하기 - 박태성(IDEASAM) :: AWS Community Day 2020
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017Bootiful Development with Spring Boot and React - RWX 2017
Bootiful Development with Spring Boot and React - RWX 2017
 
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜
RESTful API を Chalice で紐解く 〜 Python Serverless Microframework for AWS 〜
 
Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017Spring5 New Features - Nov, 2017
Spring5 New Features - Nov, 2017
 

Viewers also liked

絶対落ちないアプリの作り方
絶対落ちないアプリの作り方絶対落ちないアプリの作り方
絶対落ちないアプリの作り方Fumihiko Shiroyama
 
Android lint-srp-practice
Android lint-srp-practiceAndroid lint-srp-practice
Android lint-srp-practicecch-robo
 
What is tested by pre-launch (security) reports?
What is tested by pre-launch (security) reports?What is tested by pre-launch (security) reports?
What is tested by pre-launch (security) reports?ak_shio_555
 
全てSになる -RxJavaとLWSを持ち込む楽しさ-
全てSになる -RxJavaとLWSを持ち込む楽しさ-全てSになる -RxJavaとLWSを持ち込む楽しさ-
全てSになる -RxJavaとLWSを持ち込む楽しさ-Ryutaro Miyashita
 
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介minneにおけるテスト〜リリース〜リリース後にやっている事の紹介
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介Masataka Kono
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiYukiya Nakagawa
 
Firebase를 이용한 호우호우 미니게임 만들기
Firebase를 이용한 호우호우 미니게임 만들기Firebase를 이용한 호우호우 미니게임 만들기
Firebase를 이용한 호우호우 미니게임 만들기Yong-sang Lee
 
New android location ap is
New android location ap isNew android location ap is
New android location ap isVishal Nayak
 
Google Play Game Servicesについて
Google Play Game ServicesについてGoogle Play Game Servicesについて
Google Play Game ServicesについてKenzo Ishii
 
Ops worksに今後期待するところ
Ops worksに今後期待するところOps worksに今後期待するところ
Ops worksに今後期待するところFumihiko Shiroyama
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleKeishin Yokomaku
 
GCP HTTPロードバランサ運用例
GCP HTTPロードバランサ運用例GCP HTTPロードバランサ運用例
GCP HTTPロードバランサ運用例Fumihiko Shiroyama
 
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!Shinobu Okano
 
実践アニメーション
実践アニメーション実践アニメーション
実践アニメーションNaoya Yunoue
 
Androidアプリのストレージ戦略
Androidアプリのストレージ戦略Androidアプリのストレージ戦略
Androidアプリのストレージ戦略Masahiro Hidaka
 

Viewers also liked (19)

絶対落ちないアプリの作り方
絶対落ちないアプリの作り方絶対落ちないアプリの作り方
絶対落ちないアプリの作り方
 
Android lint-srp-practice
Android lint-srp-practiceAndroid lint-srp-practice
Android lint-srp-practice
 
What is tested by pre-launch (security) reports?
What is tested by pre-launch (security) reports?What is tested by pre-launch (security) reports?
What is tested by pre-launch (security) reports?
 
全てSになる -RxJavaとLWSを持ち込む楽しさ-
全てSになる -RxJavaとLWSを持ち込む楽しさ-全てSになる -RxJavaとLWSを持ち込む楽しさ-
全てSになる -RxJavaとLWSを持ち込む楽しさ-
 
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介minneにおけるテスト〜リリース〜リリース後にやっている事の紹介
minneにおけるテスト〜リリース〜リリース後にやっている事の紹介
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
 
Firebase를 이용한 호우호우 미니게임 만들기
Firebase를 이용한 호우호우 미니게임 만들기Firebase를 이용한 호우호우 미니게임 만들기
Firebase를 이용한 호우호우 미니게임 만들기
 
New android location ap is
New android location ap isNew android location ap is
New android location ap is
 
Google io 2013_keynote
Google io 2013_keynoteGoogle io 2013_keynote
Google io 2013_keynote
 
Wallet api
Wallet apiWallet api
Wallet api
 
Dive Into Google Glass
Dive Into Google GlassDive Into Google Glass
Dive Into Google Glass
 
Google Play Game Servicesについて
Google Play Game ServicesについてGoogle Play Game Servicesについて
Google Play Game Servicesについて
 
Ops worksに今後期待するところ
Ops worksに今後期待するところOps worksに今後期待するところ
Ops worksに今後期待するところ
 
Google I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と GradleGoogle I/O 2013 報告会 Android Studio と Gradle
Google I/O 2013 報告会 Android Studio と Gradle
 
GCP HTTPロードバランサ運用例
GCP HTTPロードバランサ運用例GCP HTTPロードバランサ運用例
GCP HTTPロードバランサ運用例
 
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!
OnActivityResult - おまえら!もうonActivityResultでswitchとif書く時代は終わりだぞ!
 
Whats new in_play
Whats new in_playWhats new in_play
Whats new in_play
 
実践アニメーション
実践アニメーション実践アニメーション
実践アニメーション
 
Androidアプリのストレージ戦略
Androidアプリのストレージ戦略Androidアプリのストレージ戦略
Androidアプリのストレージ戦略
 

Similar to Firebase with Android

Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overviewMaksym Davydov
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv Startup Club
 
Angular JS2 Training Session #3
Angular JS2 Training Session #3Angular JS2 Training Session #3
Angular JS2 Training Session #3Paras Mendiratta
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Michael Plöd
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJoshua Long
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenJoshua Long
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsLoiane Groner
 
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012Amazon Web Services
 

Similar to Firebase with Android (20)

Apresentação firebase
Apresentação firebaseApresentação firebase
Apresentação firebase
 
Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overview
 
Firebase
FirebaseFirebase
Firebase
 
Firebase overview
Firebase overviewFirebase overview
Firebase overview
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
ABCD firebase
ABCD firebaseABCD firebase
ABCD firebase
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
Lviv MDDay 2014. Ігор Коробка “забезпечення базової безпеки в андроїд аплікац...
 
2015 akure gdg dev fest
2015 akure gdg dev fest2015 akure gdg dev fest
2015 akure gdg dev fest
 
Firebase
Firebase Firebase
Firebase
 
Angular JS2 Training Session #3
Angular JS2 Training Session #3Angular JS2 Training Session #3
Angular JS2 Training Session #3
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
LiveOps para games usando o Firebase
LiveOps para games usando o FirebaseLiveOps para games usando o Firebase
LiveOps para games usando o Firebase
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
MBL301 Data Persistence to Amazon Dynamodb for Mobile Apps - AWS re: Invent 2012
 

Recently uploaded

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 

Recently uploaded (20)

Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 

Firebase with Android

  • 3. Firebase • Realtime Database • Authentication & Access Control • Static Web Site Hosting
  • 4. Udacity • Firebase Essential For Android • https://www.udacity.com/course/firebase- essentials-for-android--ud009
  • 7.
  • 8.
  • 9.
  • 11. android { ... packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE-FIREBASE.txt' exclude 'META-INF/NOTICE' } }
  • 13. Custom Application public class MyApplication extends Application {
 @Override
 public void onCreate() {
 super.onCreate();
 Firebase.setAndroidContext(this);
 }
 }
  • 16. AndroidManifest.xml Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").setValue("hello firebase!");
  • 17. Activity Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").setValue("hello firebase!"); Reference
  • 18. Activity Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").setValue("hello firebase!"); Child Node
  • 19. Activity Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").setValue("hello firebase!"); Writing
  • 20.
  • 22. public class BlogPost { private String author; private String title; public BlogPost() { // empty default constructor // necessary for Firebase to be able to deserialize blog posts } public String getAuthor() { return author; } public String getTitle() { return title; } }
  • 24. NoSQL JSON Tree { "users": { "mchen": { "friends": { "brinchen": true }, "name": "Mary Chen", // our child node appears in the existing JSON tree "widgets": { "one": true, "three": true } }, "brinchen": { ... }, "hmadi": { ... } } }
  • 25. NoSQL JSON Tree { "users": { "mchen": { "friends": { "brinchen": true }, "name": "Mary Chen", // our child node appears in the existing JSON tree "widgets": { "one": true, "three": true } }, "brinchen": { ... }, "hmadi": { ... } } }
  • 26. NoSQL JSON Tree { "users": { "mchen": { "friends": { "brinchen": true }, "name": "Mary Chen", // our child node appears in the existing JSON tree "widgets": { "one": true, "three": true } }, "brinchen": { ... }, "hmadi": { ... } } } /users/mchen/widgets
  • 27. NoSQL JSON Tree { "users": { "mchen": { "friends": { "brinchen": true }, "name": "Mary Chen", // our child node appears in the existing JSON tree "widgets": { "one": true, "three": true } }, "brinchen": { ... }, "hmadi": { ... } } } /users/mchen/widgets Unique Identifier
  • 29. • String • Boolean • Long • Double • Map<String, Object> • List<Object>
  • 31. Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
 Toast.makeText( MainActivity.this, dataSnapshot.getValue(String.class), Toast.LENGTH_SHORT ).show();
 }
 
 @Override
 public void onCancelled(FirebaseError firebaseError) {
 
 }
 });
  • 32. Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
 Toast.makeText( MainActivity.this, dataSnapshot.getValue(String.class), Toast.LENGTH_SHORT ).show();
 }
 
 @Override
 public void onCancelled(FirebaseError firebaseError) {
 
 }
 });
  • 33. Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
 Toast.makeText( MainActivity.this, dataSnapshot.getValue(String.class), Toast.LENGTH_SHORT ).show();
 }
 
 @Override
 public void onCancelled(FirebaseError firebaseError) {
 
 }
 });
  • 34. Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
 Toast.makeText( MainActivity.this, dataSnapshot.getValue(String.class), Toast.LENGTH_SHORT ).show();
 }
 
 @Override
 public void onCancelled(FirebaseError firebaseError) {
 
 }
 });
  • 35. Firebase firebaseRef = new Firebase("https://shiroyama-app-01.firebaseio.com/");
 firebaseRef.child("message").addValueEventListener(new ValueEventListener() {
 @Override
 public void onDataChange(DataSnapshot dataSnapshot) {
 Toast.makeText( MainActivity.this, dataSnapshot.getValue(String.class), Toast.LENGTH_SHORT ).show();
 }
 
 @Override
 public void onCancelled(FirebaseError firebaseError) {
 
 }
 });
  • 37. • Value • Child Added • Child Changed • Child Removed • Child Moved
  • 38. Value Event • ValueEventListener#onDataChange • Retrieve whole data at once • Called once at initial time, then every time data changes.
  • 39. // Get a reference to our posts Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts"); // Attach an listener to read the data at our posts reference ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { System.out.println("There are " + snapshot.getChildrenCount() + " blog posts"); for (DataSnapshot postSnapshot: snapshot.getChildren()) { BlogPost post = postSnapshot.getValue(BlogPost.class); System.out.println(post.getAuthor() + " - " + post.getTitle()); } } @Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } });
  • 40. // Get a reference to our posts Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts"); // Attach an listener to read the data at our posts reference ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { System.out.println("There are " + snapshot.getChildrenCount() + " blog posts"); for (DataSnapshot postSnapshot: snapshot.getChildren()) { BlogPost post = postSnapshot.getValue(BlogPost.class); System.out.println(post.getAuthor() + " - " + post.getTitle()); } } @Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } });
  • 41. // Get a reference to our posts Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts"); // Attach an listener to read the data at our posts reference ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { System.out.println("There are " + snapshot.getChildrenCount() + " blog posts"); for (DataSnapshot postSnapshot: snapshot.getChildren()) { BlogPost post = postSnapshot.getValue(BlogPost.class); System.out.println(post.getAuthor() + " - " + post.getTitle()); } } @Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } });
  • 42. Child Added Event • ChildEventListener#onChildAdded • Once for each existing child initially • Every time new data is added
  • 43. // Get a reference to our posts Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts"); ref.addChildEventListener(new ChildEventListener() { // Retrieve new posts as they are added to the database @Override public void onChildAdded(DataSnapshot snapshot, String previousChildKey) { BlogPost newPost = snapshot.getValue(BlogPost.class); System.out.println("Author: " + newPost.getAuthor()); System.out.println("Title: " + newPost.getTitle()); } //... ChildEventListener also defines onChildChanged, onChildRemoved, // onChildMoved and onCanceled, covered in later sections. });
  • 44. Child Changed Event • ChildEventListener#onChildChanged • Anytime a child is changed including its descendants
  • 45. @Override public void onChildChanged(DataSnapshot snapshot, String previousChildKey) { String title = (String) snapshot.child("title").getValue(); System.out.println("The updated post title is " + title); }
  • 46. Child Removed Event • ChildEventListener#onChildRemoved • Anytime a child is removed
  • 47. @Override public void onChildRemoved(DataSnapshot snapshot) { String title = (String) snapshot.child("title").getValue(); System.out.println("The blog post titled " + title + " has been deleted"); }
  • 48. Child Moved Event • ChildEventListener#onChildMoved • Anytime a child is moved
  • 49. @Override public void onChildMoved(DataSnapshot snapshot, String previousChildKey) { String title = (String) snapshot.child("title").getValue(); System.out.println("The updated post title is " + title); }
  • 50. Detaching Callbacks • ref.removeEventListener(originalListener); • all listeners must be removed explicitly • removing parent listener will NOT remove child's listeners
  • 52. ref.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { // do some stuff once } @Override public void onCancelled(FirebaseError firebaseError) { } });
  • 53. ref.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { // do some stuff once } @Override public void onCancelled(FirebaseError firebaseError) { } });
  • 55. { "lambeosaurus": { "height" : 2.1, "length" : 12.5, "weight": 5000 }, "stegosaurus": { "height" : 4, "length" : 9, "weight" : 2500 } }
  • 56. public class DinosaurFacts { long height; double length; long weight; public DinosaurFacts() { // empty default constructor // necessary for Firebase to be able to deserialize blog posts } public long getHeight() { return height; } public double getLength() { return length; } public long getWeight() { return weight; } }
  • 57. • orderByChild() • orderByKey() • orderByValue() • orderByPriority()
  • 58. orderByChild Query queryRef = ref.orderByChild("height"); or Query queryRef = ref.orderByChild("dimensions/height");
  • 59. orderByKey Query queryRef = ref.orderByKey(); { "lambeosaurus": { "height" : 2.1, "length" : 12.5, "weight": 5000 }, "stegosaurus": { "height" : 4, "length" : 9, "weight" : 2500 } }
  • 60. orderByValue Query queryRef = ref.orderByValue(); { "scores": { "bruhathkayosaurus" : 55, "lambeosaurus" : 21, "linhenykus" : 80, "pterodactyl" : 93, "stegosaurus" : 5, "triceratops" : 22 } }
  • 61. orderByPriority Query queryRef = ref.orderByPriority();
  • 62. orderByPriority Query queryRef = ref.orderByPriority(); arbitrary priority you set
  • 63. • limitToFirst() • limitToLast() • startAt() • endAt() • equalTo()
  • 64. Query queryRef = ref.orderByChild("height").limitToFirst(2); Query queryRef = scoresRef.orderByValue().limitToLast(3); Query queryRef = ref.orderByChild("height").startAt(3); Query queryRef = ref.orderByKey().endAt("pterodactyl"); Query queryRef = ref.orderByChild("height").equalTo(25);
  • 66.
  • 67. { "rules": { "users": { "$user_id": { ".write": "$user_id === auth.uid" } } } }
  • 68. { "rules": { "users": { "$user_id": { ".write": "$user_id === auth.uid" } } } }
  • 69. { "rules": { "users": { "$user_id": { ".write": "$user_id === auth.uid" } } } } talks about this later
  • 72. • helper libraries to integrate with your own authentications • https://www.firebase.com/docs/android/ guide/login/custom.html#section-rest-token- helper-libraries
  • 73. Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/"); ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() { @Override public void onAuthenticationError(FirebaseError error) { System.err.println("Login Failed! " + error.getMessage()); } @Override public void onAuthenticated(AuthData authData) { System.out.println("Login Succeeded!"); } });
  • 74. Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/"); ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() { @Override public void onAuthenticationError(FirebaseError error) { System.err.println("Login Failed! " + error.getMessage()); } @Override public void onAuthenticated(AuthData authData) { System.out.println("Login Succeeded!"); } });
  • 75. Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/"); ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() { @Override public void onAuthenticationError(FirebaseError error) { System.err.println("Login Failed! " + error.getMessage()); } @Override public void onAuthenticated(AuthData authData) { System.out.println("Login Succeeded!"); } }); given from your server
  • 76. Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com/"); ref.authWithCustomToken(AUTH_TOKEN, new Firebase.AuthResultHandler() { @Override public void onAuthenticationError(FirebaseError error) { System.err.println("Login Failed! " + error.getMessage()); } @Override public void onAuthenticated(AuthData authData) { System.out.println("Login Succeeded!"); } });
  • 78. Tips
  • 79. • SwipeRefresh should be used with ValueEvent(once)
  • 81. • No File Uploading APIs • Server side batching • Server side scheduling • Server side event hook
  • 82. Q & A
  • 84. • Chat • https://github.com/firebase/AndroidChat • Drawing • https://github.com/firebase/AndroidDrawing
  • 85. THX!