Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Android-Programming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Android-Programming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Programming

What is an app?

An application is a software
program:
• Designed to perform a
specific function directly for
the user(s)
• Usually obtained through
the web or mobile devices
• Made to run inside an
operating system (i.e.
Android, Windows)
How are apps developed?
Setup
• Setup you development environment (i.e. Android Studio)
• Setup devices for testing (virtual or hardware devices)
• Have an idea for an app
Development
• Create your application (Coding)
Debugging and Testing
• Build and run your application (Compiling Code)
• Debug your application
• Test your application on emulator or device
Publishing
• Prepare your application for release
• Release application (i.e. to Play Store)
GETTING STARTED
Download Android Studio - Download Here

More Information Will Be On Webpage


(i.e. System Requirements, Options for Downloads).
After downloading open the file and follow the install wizard.

Would recommend having system that has at least 2GB free


RAM
this is to be set aside for your virtual device.
Also the latest version of Java is necessary especially if
developing for Android 5.0 and higher.
Click Here To Check Version
This should be the start up menu
when you first open the
application.

Let’s first try using a sample code.


Click where it says “Import an
Android code sample”.

It should prompt you to choose


from a variety. Let’s go with “Basic
Gesture Detect”. Click and then hit
next. Then it should ask what you
want to name and the location of
its folder. (Would just keep as is).
Then hit finish, it takes time for it
to load up.

We will come back to this.


Once everything is loaded click on the SDK manager indicated
with the blue arrow. Then click on SDK tools, and make sure
you have Intel x86 Emulator Accelerator installed (indicated by
red arrow). If not then please install this, it will be used to have
virtual devices. We will come back to Android Studio later.
Features
• Realtime database - stop worrying about how to
deal with storing and managing your data. Their
cloud base allows for all clients to be synced in
realtime.
• Authentication - allow access to specific users
using your preferred system. (i.e. Facebook,
email, etc.)
• Hosting - deploy in a matter of seconds, defer to
previous versions, and serve over secured
connection (SSL). Also your app gets its own
firebase domain ($5 for custom domain).

Click Here To Sign Up With Your Google Account

Click Here To Sign Up If You Don't Have A Google Account


You should go through their 5 minute tutorial to get familiar with their
website. Once done you can create a new app and obtain a domain
for it as shown here.
Realtime Database
To save this app’s data on
firebase.com, go to
File -> Project Structure

Then click on “Cloud” and check the


box
next to Firebase. And hit OK.

Now click on “1: Project” and double


click on “build.gradle(Module:
Application”. Shown below.
Now you will have to add this inside “ android {…}”. This is just to
ensure you will not get any build errors about duplicate files.

Now in the same “1: Project” tab, where the red arrow is pointing add :
Firebase.setAndroidContext(this);
Now click on “BasicGestureDetectFragment”. And for every event that you want to save
data for add:

Firebase myFirebaseRef = new Firebase(“https://(Your App Domain Here).firebaseio.com/(Parent Name here)”);


myFirebaseRef.child(“(Child Name Here)”).setValue((Data Type Here));

So for our example it would be :


Firebase myFirebaseRef = new Firebase(“https://(Your App Domain Here).firebaseio.com/Click”);
myFirebaseRef.child(“Long Press”).setValue(true);

Do this for each of the gestures and make sure to change the name of “child”.
Hit the green play button to run your
application and launch the emulator.
Your app will take a minute or two to
appear on the virtual device. While its
loading go to your app’s firebase domain
it should look like the image below
Android Studio shows you the performance that your app
requires of the CPU, GPU, Memory, and Network.

In realtime you should see your data appear on your firebase database.
If you would like more information on saving or retrieving data click here .
Authentication
Within your firebase
dashboard click over to the
“Login & Auth” tab.

Email & Password is the


simplest one so let’s work
with this one.

Click the “Add User” button


(indicated by red arrow)
where is should prompt you
to provide the email and
password for the user

[email must have “@“ and


password must be >4
characters in length]
It should then add to list of users and create a “User UID”

There are more forms of authentication that can be


Added to your project such as: Facebook, Google, Twitter, etc.
Documentation can be found here
HOSTING
• You will require Node.js (which includes npm) : Click Here to Download

Once installed you can install firebase command line tools via npm:

Copy and paste this: $ npm install -g firebase-tools

Or use sudo (with caution) if required by your system permissions

Copy and paste this: sudo npm install -g firebase-tools

You can now update if necessary : $ npm update –g firebase-tools

Or sudo npn update –g firebase-tools


HOSTING CONTINUED
• Initializing Your Site

To initialize your project first “cd” to the project’s root directory and run : $ firebase init

• Deploying Your Site

Run from your project directory: $ firebase deploy

This will deploy your project to :

<your-firebase-app>.firebaseapp.com

Note: Firebase Hosting is SSL-only so content will only be served over HTTPS.
THE FIREBASE.JSON FILE

The firebase init command makes this setting file in the root of your projects
directory. It is to configure what files are published upon deployment.

Should look something like this:

Note: These are defaults and advanced properties such as rules, redirects, and
rewrites can be added. For documentation here.
“There are two ways of constructing a software design.
One way is to make it so simple that there are obviously no deficiencies.
And the other way is to make it so complicated that there are no obvious deficiencies.”
(C.A.R. Hoare)

You might also like