fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,113 @@
---
title: Android core components
---
# Android core components
Core components are the essential elements which an app for Android consists of. Each of them has its own purpose and lifecycle but not all of them are independent. They are:
- Activities
- Services
- Broadcast receivers
- Content providers
## [Activities](https://developer.android.com/guide/components/activities/)
An _activity_ is a component that has a user interface and represents a single screen. An app can have multiple activities, each of those can be an entry point to the application itself for the user or the system (an app's activity that wants to open another activity that belongs to the same application or to a different one).
### [Activity Lifecycle](https://developer.android.com/guide/components/activities/activity-lifecycle)
![Activity Lifecycle](https://developer.android.com/images/activity_lifecycle.png)
* onCreate():
> Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously frozen state, if there was one. Always followed by onStart().
* onRestart():
> Called after your activity has been stopped, prior to it being started again. Always followed by onStart()
* onStart():
> Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
* onResume():
> Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it. Always followed by onPause().
* onPause ():
> Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed. The counterpart to onResume(). When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here.
* onStop():
> Called when you are no longer visible to the user. You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity.
>Note that this method may never be called, in low memory situations where the system does not have enough memory to keep your activity's process running after its onPause() method is called.
* onDestroy():
> The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between> these two scenarios with the isFinishing() method.
#### Sample code to understand Activity Lifecycle
``` java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends Activity {
String tag = "LifeCycleEvents";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(tag, "In the onCreate() event");
}
public void onStart()
{
super.onStart();
Log.d(tag, "In the onStart() event");
}
public void onRestart()
{
super.onRestart();
Log.d(tag, "In the onRestart() event");
}
public void onResume()
{
super.onResume();
Log.d(tag, "In the onResume() event");
}
public void onPause()
{
super.onPause();
Log.d(tag, "In the onPause() event");
}
public void onStop()
{
super.onStop();
Log.d(tag, "In the onStop() event");
}
public void onDestroy()
{
super.onDestroy();
Log.d(tag, "In the onDestroy() event");
}
}
```
## [Services](https://developer.android.com/guide/components/services)
A _service_ is a component without user interface to perform long-running operations in the background.
There are two kinds of services:
- _foreground_ services: they are strictly related to user's interaction (for example music playback), so it's harder for the system to kill them.
- _background_ services: they are not directly related to user's activities, so they can be killed if more RAM is needed.
## [Broadcast receivers](https://developer.android.com/guide/components/broadcasts)
A _broadcast receiver_ is another component without user interface (except an optional status bar notification) that lets the system to deliver events from/to the app, even when the latter hasn't been previously launched.
## [Content providers](https://developer.android.com/guide/topics/providers/content-providers)
A _content provider_ is a component used to manage a set of app data to share with other applications. Each item saved in the content provider is identified by a URI scheme.
For detailed information about the topic, see the official [Android fundamentals](https://developer.android.com/guide/components/fundamentals) documentation.
## Advanced Android Development
To learn advanced Android programming concepts, see Google's [Advanced Android Development](https://developers.google.com/training/courses/android-advanced) course.

View File

@ -0,0 +1,44 @@
---
title: connecting-to-firebase
---
# Prerequisites
1. The Latest Version of Android Studio
<br>
The easiest way to connect to firebase is to use the firebase assistant.
# 1. Connecting using Firebase Assistant
1. Create an account in the [Firebase Console](https://console.firebase.google.com).
Click add project to add your Android Studio project to it.
2. Install Google Repository
You can do this by adding the dependency into your project-level build.gradle file like this:
```java
allprojects{
repositories {
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
```
Alternatively, you could do that [using the GUI](https://developer.android.com/studio/write/firebase).
3. Go to Tools > Firebase and select Connect to Firebase
If you wish to connect to firebase manually, detailed instructions are available [here](https://firebase.google.com/docs/android/setup).
<br>
Having connected your Android Studio project to Firebase, you can either
1. click on a product in the firebase assistant and get taken to the Google docs where you will be told how to proceed
2. go to desired product in **Project Overview** in the Console and click on **Get Started**
3. go to the [Firebase docs](https://www.firebase.com/docs/android/quickstart.html) to see how to setup individual products in your project
Reading a combination of all three will enable you to setup the product, which includes adding suitable dependencies to your build.gradle file.
**If You Encounter Gradle Sync**
Try To Change The Firebase-core Version or Firebase-database version

View File

@ -0,0 +1,51 @@
---
title: Setting up Firebase Storage
---
# Setting up Firebase Storage
## Prerequisites
1. The latest version of Android Studio
2. Have connected with Firebase manually or via Firebase Assistant (See [Connecting to Firebase](guide/src/pages/android-development/firebase/connecting-to-firebase)).
It is recommended that you do this so as to not be confused by partial instructions related to this in the docs mentioned below.
## Setting it up with Android Studio
After adding Firebase to your project, you will need to add extra dependencies and do some other things in order to setup
the Firebase Storage. There are following documentation about this:
* [Firebase](https://firebase.google.com/docs/storage/android/start)
There may be chance of confusion in that documentation or if you are new to firebase then you may face little bit hard to understand it.
So follow the belows steps carefully:
**Add Gradle Dependencies**
In your app-level build.gradle file, add the following
```java
dependencies {
implementation 'com.google.firebase:firebase-storage:16.0.2'
}
```
## Installation of Firebase Android SDK, permissions and setup code
Detailed instructions for these can be found [here](https://firebase.google.com/docs/android/setup).
## Resources
To learn about how to read from and write to the storage in your Android application, refer to the docs listed below.
* [Upload files from Android
Firebase Guide](https://firebase.google.com/docs/storage/android/upload-files)
* [Download files to Android
Firebase Guide](https://firebase.google.com/docs/storage/android/download-files)
## Sample Projects from Firebase Developers
You can follow up these samples from Firebase developers to get started Firebase storage
Firebase Quickstart-Android [android-sample](https://github.com/firebase/quickstart-android/tree/master/storage)
## Note
Google now deprecated 'compile' and in place of that you need to use 'implementation'.

View File

@ -0,0 +1,54 @@
---
title: Setting up Firebase Realtime Database
---
# Prerequisites
1. The latest version of Android Studio
2. Have connected with Firebase manually or via Firebase Assistant(See [Connecting to Firebase](guide/src/pages/android-development/firebase/connecting-to-firebase)).
<br>
It is recommended that you do this so as to not be confused by partial instructions related to this in the docs mentioned below.
# Setting it up with Android Studio
<br>
After adding Firebase to your project, you will need to add extra dependencies and do some other things in order to setup
the Realtime Database. There are two documentations about this:
1. Firebase quickstart [docs](https://www.firebase.com/docs/android/quickstart.html)
2. Google [docs](https://firebase.google.com/docs/database/android/start/)
There are some discrepancies between the two.
To make up for them, you can follow the Firebase docs, but instead of just using the gradle dependencies listed there, use the following list.
That way, you will not miss any steps from either documentation.
<br>
**Add Gradle Dependencies**<sup>1</sup>
<br>
In your app-level build.gradle file, add the following
<br>
```java
dependencies {
implementation 'com.firebase:firebase-client-android:2.5.2+'
implementation 'com.google.firebase:firebase-database:15.0.0'
}
```
# Installation of Firebase Android SDK, permissions and setup code
Detailed instructions for these can be found [here](https://www.firebase.com/docs/android/quickstart.html).
# Resources
To learn about how to read from and write to the database in your Android application, refer to the two docs listed in References.
<br>
You can also find out how to use Firebase products in the Google documentation, but again it is probably a good idea to look at the Firebase docs as well, or anything that might be helpful.
# References
- FIREBASE, _Android Quickstart_, 17/04/2018, 07/05/2018, https://www.firebase.com/docs/android/quickstart.html
- GOOGLE, _Set up Firebase Realtime Database for Android_, 05/04/2018, 07/05/2018, https://firebase.google.com/docs/database/android/start/
# Footnote
The first line comes from the Firebase [docs](https://www.firebase.com/docs/android/quickstart.html) on setting up realtime db in Android Studio.
<br>
In the docs, 'compile' is used but that is deprecated and replaced by 'implementation'.
<br>
The second line comes from the Google [docs](https://firebase.google.com/docs/database/android/start/) on setting up realtime db in Android Studio.
<br>
If it is actually redundant to add both, please correct this article.

View File

@ -0,0 +1,65 @@
---
title: Android Development
---
# Android Development
Android apps can be a great, fun way to get into the world of programming. Officially programmers can use Java, Kotlin, or C++ to develop for Android, and though there may be API restrictions, using tools, developers can use a large number of languages, including JavaScript, C, or assembly, and the possibilities are endless.
From simple games and utility apps to full-blown music players, there are many opportunities to create something meaningful with Android. The Android developer community is widespread, and the documentation and resources online are easy to find, so that you can tackle any issue you're facing.
There is definitely a learning curve to get used to the Android framework, however once you understand the core components that make up the app, the rest will come naturally.
The learning curve involved in Android has a relatively smaller slope as compared to learning other technologies such as NodeJS. It is also relatively easier to understand and make contributions towards AOSP hosted by Google. The project can be found [here](https://source.android.com/)
## Getting started
Check out the guides in this folder to learn about the 4 [core components](core-components/index.md) that make up an Android app and how you can get started with a sample app, and then delve into the more advanced topics such as fragments and the Gradle build system. Then check out the material design specifications guide as well to learn how to make your apps beautiful and user friendly.
### Setting Up and Getting Started with Android Studio
Go to this [link](https://www.oracle.com/technetwork/java/javase/downloads/index.html) and install the latest JDK.
Now download the Android Studio and SDK tools bundle from [here](https://developer.android.com/studio/).
Install the Android Studio and SDK following the set up. Keep note of the SDK location.
If you face any error go to settings later to solve it.
Lastly, learn to integrate 3rd party libraries and Firebase services to add functionality to your app. It would be helpful if you go through the official documentation for each component.
### Official Documentation
[Google Developers Guide for Android](https://developer.android.com/training/index.html)
#### Java vs. Kotlin
Ever since Google announced Kotlin as the official language for Android development at Google IO in 2017, programmers who want to become Android developers are in a dilemma. The big question in front of them is whether they should learn Kotlin or Java.
##### Beginners in Android Development Should Start With Java
The first and foremost thing is that Android development is not everything; as a programmer, you may be starting your career with Android development, but if you start with a well-established language like Java, you become a part of the bigger Java community and market, which directly means more job opportunities.
The second and more important thing is that there is a huge community of Java programmers, which means you can find answers when you are stuck. This is very important because, as a beginner, you will face a lot of technical problems and you might not know where to head when you are stuck. When you search Google with a Java problem, you are bound to get answers; the same cannot be said for Kotlin, which is still a new programming language.
###### Java Programmers Should Learn Kotlin
Now, coming back to the second set of programmers who wants to learn Android development: our fellow Java developers. For them, I think its best to learn Kotlin because it really improves productivity.
A class which takes 50 lines of code in Java can really be written in just one line in Kotlin. It can help you avoid all boiler-plate code, e.g. you don't need to specify getters and setters, equals(), hashCode() or toString() methods. Kotlin can generate all that by itself.
If you don't know, Kotlin was development by JetBrains, the company behind one of the most popular Java IDEs, IntelliJ IDEA. They were a Java shop and developing IDEs like IntelliJ IDEA, PyCharm, and ReSharper, all in Java, and built Kotlin to improve their productivity, but at the same time, they cannot rewrite all their code in Kotlin, so that's why they made Kotlin fully interoperable with Java.
Because Kotlin generates Java bytecode, you can use your favorite Java frameworks and libraries in Kotlin and your Java friends can also use any Kotlin framework you develop.
### Practice
[Codelabs for Boosting up Skills](https://codelabs.developers.google.com)
### Google Developer Console
[Google Developer Console](https://developer.android.com/distribute/console/)
### Courses
[Udacity Android Nanodegree Program](https://udacity.com/course/android-developer-nanodegree-by-google--nd801)
### Developing Android Apps
The best part of learning Android is that many of the courses and material available out there online are free.
The link to the basic course is here - [Developing Android Apps](https://udacity.com/course/new-android-fundamentals--ud851).
The link to the advanced course is here - [Advanced Android App Development](https://www.udacity.com/course/advanced-android-app-development--ud855).