0% found this document useful (0 votes)
18 views

Mobile APP Development Training Slides

Uploaded by

muradiabdu123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Mobile APP Development Training Slides

Uploaded by

muradiabdu123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 69

Mobile Application development

Training

By: Mohammed Abdukadir (MA.)

For Damina E-learning

1
Outline
Introduction to Mobile Application
Development
Mobile Application Tools
Android System Overview
Getting Started With Android Studio IDE

2
What is Mobile Application
Development?

Mobile application development is the set of


processes and procedures involved in writing
software for small, wireless computing devices such
as smartphones or tablet

Mobile application development is similar to web


application development and has its roots in
software development.
3
Mobile Application Tools

Mobile Application Tools are also known as Mobile IDEs


which mean Mobile Integrated Development Environments

• The tools include:


• ANDROID STUDIO
• ECLIPSE
• NETBEANS
• INTELLIJIDEA
• XAMARIN
• CORDOVA E.T.C
4
Android System Overview
There are more than a two billion smartphones and
tablet PC users worldwide. There is a growing
expectation that everything and anything will be
available as a mobile application.

More and more organization are benefiting from


improving business processes by providing their
users with access to application via their mobile
devices and tablet.

5
Introduction to Android
What is Android
Android is an operating system for mobile devices such
as smartphones and tablet computers. It is developed by the Open
Handset Alliance led by Google.

Android has beaten Apple iOS, being the leading mobile operating
system from first quarter of 2011

Version: Android 1.0, 1.1 to 1.5 (Cupcake), 1.6 (Donut), 2.0/2.1


(Eclair), 2.2 (Froyo), 2.3 (Gingerbread), to 3.0 (Honeycomb), 4.0
(Ice Cream Sandwich), 5.0 (Lollipop)

6
TOP U.S SMARTPHONE OS
SHARE
Popular mobile
device OS: 52% of
U.S. smartphone
market
Developed by Open
Handset Alliance,
led by Google
Google claims
900,000 Android
device activations

7
Android Architecture
Android System Overview

Shared Preferences: Store data as key-value pairs.


Internal Storage: Store data on the device memory. Data
will not be accessed by other application.
External Storage: Store public data on the shared external
storage. Data will be accessed by other application.
SQLite Databases: Store structured data in a private
database.
Network Connection: Store data on the Web with your own
network server.
Check Box Preference: CheckBoxPreference is used to
store data in preferences using CheckBox widget. In other
words, it provides the checkbox widget functionality

10
List Preference: ListPreference is used to display the list of entries as a dialog from
which a user can choose a single selection. This displays a group of radio buttons as
shown in figure among which only one button can be selected.
Edit Text Preference: This opens up the dialog box where user can
enter a value as shown in the figure. When text is typed into the field,
it returns a string value

12
GETTING STARTED WITH ANDROID
STUDIO

Android Studio is the official Integrated Development


Environment (IDE).
It was announced on May 16th, 2013 at the Google I/O
conference.
The interface comprises of the following:
• Menu bars
• Project Side
• Structure
• Captures
• Build Variants
• Favorite
• Preview etc
13
Android Studio IDE
Interface
14
Android Studio Requirement
Windows OS X/macOS Linux
Mac OS X
10.9.5 or
Microsoft
higher, up to GNOME or KDE
OS version Windows 10/8/7
n 2.x 10.11.6 (El desktop
(32- or 64-bit)
Capitan) or
10.12.1 (Sierra)
RAM 2 GB RAM minimum, 8 GB RAM recommended
500 MB disk space for Android Studio, at least 1.5
Disk space GB for Android SDK, emulator system images, and
caches
Java version Java Development Kit (JDK) 8
Screen
1280x800 minimum screen resolution
resolution

15
Getting Started (1)
Need to install Java Development Kit (JDK) to
write
Java (and Android) programs
Do not install Java Runtime Environment (JRE);
JDK and JRE are different!
Can download the JDK for your OS at
http://java.oracle.com
Alternatively, for OS X, Linux:
OS X:
 Open /Applications/Utilities/Terminal.app
 Type javac at command line
 Install Java when prompt appears
Linux:
 Type sudo apt–get install default–jdk at command line
(Debian, Ubuntu)
 Other distributions: consult distribution’s documentation
16
Install!

17
Getting Started (2)
After installing JDK, download Android SDK from
http://developer.android.com
Simplest: download and install Android Studio bundle
(including Android SDK) for your OS
Alternatives:
Download/install Android Developer Tools from this site
(based on Eclipse)
Install Android SDK tools by themselves, then install ADT
for Eclipse separately (from this site)
We’ll use Android Studio with SDK included (easy)

18
Install!

19
Getting Started (3)
 Install Android Studio directly (Windows, Mac); unzip to directory
android-studio, then run ./android-studio/bin/studio.sh (Linux)

20
Getting Started (4)
 Strongly recommend
testing with real
Android device
 Android emulator: very Settings
slow
 Faster emulator:
Genymotion
 Install USB drivers for
your Android device!
 Bring up the Android
SDK Manager
 Recommended: Install
Android 2.2, 2.3.3 APIs
and 4.x API
 Do not worry about Intel Now you’re ready for Android development!
21 x86 Atom, MIPS system
images
Outline
Introduction to Android
Getting Started
Android Programming

22
Android Highlights (1)
Android apps execute
on Dalvik VM, a “clean-
room” implementation
of JVM
Dalvik optimized for
efficient execution
Dalvik: register-based
VM, unlike Oracle’s stack-
based JVM
Java .class bytecode
translated to Dalvik
EXecutable (DEX)
bytecode, which Dalvik
24
interprets
Android Highlights (2)
Android apps written in Java 5
Actually, a Java dialect (Apache Harmony)
Everything we’ve learned still holds
Apps use four main components:
Activity: A “single screen” that’s visible to user
Service: Long-running background “part” of app
(not separate process or thread)
ContentProvider: Manages app data (usually
stored in database) and data access for queries
BroadcastReceiver: Component that listens for
particular Android system “events”, e.g., “found
wireless device”, and responds accordingly

25
App Manifest
Every Android app must include an Android Manifest.xml
file describing functionality
The manifest specifies:
App’s Activities, Services, etc.
Permissions requested by app
Minimum API required
Hardware features required, e.g., camera with autofocus
External libraries to which app is linked, e.g., Google Maps
library

26
Activity Lifecycle
Activity: key building
block of Android apps
 Extend Activity class,
override on Create(),
on Pause(), on
Resume() methods
 Dalvik VM can stop any
Activity without
warning, so saving state
is important!
 Activities need to be
“responsive”, otherwise
Android shows user “App
Not Responsive” warning:
 Place lengthy operations in
Runnable Threads,
27 AsyncTasks
28
App Creation Checklist
If you own an Android device:
Ensure drivers are installed
Enable developer options on device under Settings,
specifically USB Debugging
Android 4.2+: Go to Settings→About phone, press Build number
7 times to enable developer options
For Android Studio:
Under File→Settings→Appearance, enable “Show tool
window bars”; the Android view shows LogCat,
devices
Programs should log states via android.util.Log’s
Log.d(APP_TAG_STR, “debug”), where APP_TAG_STR is a
final String tag denoting your app
Other commands: Log.e() (error); Log.i() (info); Log.w()
29 (warning); Log.v() (verbose) – same parameters
Creating Android App (1)
Creating Android app project in Android
Studio:
Go to File→New Project
Enter app, project name
Choose package name using “reverse URL” notation,
e.g., edu.osu.myapp
Select APIs for app, then click Next

30
Creating Android App (2)

31
Creating Android App (3)
Determine what
kind of Activity to
create; then click
Next
We’ll choose a
Blank Activity for
simplicity
Enter information
about your Activity,
then click Finish
This creates a
“Hello World” app
32
Deploying the App
 Two choices for deployment:
 Real Android device
 Android virtual device
 Plug in your real device;
otherwise, create an Android
virtual device
 Emulator is slow. Try Intel
accelerated version, or
perhaps
http://www.genymotion.
com/
 Run the app: press “Run”
button in toolbar
33
Underlying Source Code

package edu.osu.helloandroid;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity
{
@Override
protected void on Create(Bundle saved Instance State)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); }
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if
it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
34
Underlying GUI Code
res/layout/activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
35
The App Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.osu.helloandroid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity

36
android:name="edu.osu.helloandroid.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

37
A More Interesting
App(Example)
We’ll now examine
an app with more
features: WiFi
Tester (code on
class website)
Press a button,
scan for WiFi
access points
(APs), display them

38
Underlying Source Code (1)
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wi_fi);

// Set up WifiManager.
mWifiManager = (WifiManager)
getSystemService(Context.WIFI_SERVICE);

// Create listener object for Button. When Button


is pressed, scan for
// APs nearby.
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new
View.OnClickListener()
{
39
public void onClick(View v)
{
boolean scanStarted =
mWifiManager.startScan();

// If the scan failed, log it.


if (!scanStarted) Log.e(TAG, "WiFi scan
failed...");
}
});

// Set up IntentFilter for "WiFi scan results available"


Intent.
mIntentFilter = new IntentFilter();

mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
}

40
Underlying Source Code (2)
@Override
Code much more complex protected void onResume()
First get system Wifi Manager {
super.onResume();
Create listener Object for
button that performs scans registerReceiver(mReceiver,
mIntentFilter);
We register Broadcast }
Receiver, m Receiver, to listen
for Wifi Manager’s “finished @Override
scan” system event (expressed protected void onPause()
as Intent Wifi {
super.onPause();
Manager.SCAN_RESULTS_
unregisterReceiver(mReceiver
AVAILABLE_ACTION) );
Unregister Broadcast Receiver }
when leaving Activity

41
The Broadcast Receiver
private final BroadcastReceiver mReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if
(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(action))
{
Log.e(TAG, "Scan results available");
List<ScanResult> scanResults =
mWifiManager.getScanResults();
mApStr = "";

42
for (ScanResult result : scanResults)
{
mApStr = mApStr + result.SSID + ";
";
mApStr = mApStr + result.BSSID +
"; ";
mApStr = mApStr +
result.capabilities + "; ";
mApStr = mApStr + result.frequency
+ " MHz;";
mApStr = mApStr + result.level + "
dBm\n\n";
}
// Update UI to show all this
information.
setTextView(mApStr);
}
}
};
43
User Interface
private void set Text View(String
str)
{
Text View tv = (Text View)
find View ById(R.id.text view);
tv.set Movement Method(new
Scrolling Movement Method());
tv.setText(str);
}

This code simply has


the UI display all
collected WiFi APs,
makes the text
44 information scrollable
Android Programming Notes
Android apps have multiple points of entry: no main()
method
Cannot “sleep” in Android
During each entrance, certain Objects may be null
Defensive programming is very useful to avoid crashes, e.g.,
if (!(myObj == null)) { // do something }
Java concurrency techniques are required
Don’t block the “main” thread in Activities
Implement long-running tasks such as network connections
asynchronously, e.g., as AsyncTasks
Recommendation: read Logging state via
android.util.Log throughout app is essential when
debugging (finding root causes)
Better to have “too many” permissions than too few
Otherwise, app crashes due to security exceptions!
Remove “unnecessary” permissions before releasing app to
public
Event handling in Android GUIs entails many listener
45 Objects
Android User Interface -1

The graphical user interface for an Android app is built


using a hierarchy of View and View Group objects.
View objects are usually UI widgets such as buttons or
text fields. View Group objects are invisible view
containers that define how the child views are laid out,
such as in a grid or a vertical list.
Android provides an XML vocabulary that corresponds
to the subclasses of View and View Group so you can
define your UI in XML using a hierarchy of UI
elements.

46
Android User Interface -2

47
Create a Linear Layout -1

In Android Studio's Project window, open app > res >
layout > activity_main.xml.This XML file defines the
layout of your activity. It contains the default "Hello
World" text view.
When you open a layout file, you’re first shown the
design editor in the Layout Editor. For this lesson, you
work directly with the XML, so click the Text tab at
the bottom of the window to switch to the text editor.
Delete everything and insert the following XML:

48
Create a Linear Layout-2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

xmlns:android="http://schemas.android.com/apk/r
es/android"

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>

49
Add a Text Field
<LinearLayout

xmlns:android="http://schmas.android.com/apk/res/a
ndroid"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
</LinearLayout>

50
Add Button
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>

51
Make the Input Box Fill in the Screen Width
In activity_main.xml, modify the <
Edit Text> so that the attributes look like
this:

<Edit Text
android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"

android:layout_height="wrap_content"
android:hint="@string/edit_message"
/>

52
COMPLETE UI EXAMPLE
Here’s how your complete activity_main.xmllayout file should
now look:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/androi
d"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
53
android:text="@string/button_send" />
</LinearLayout>
Android Studio practice

Developing A Simple Calculator


Mobile Application

54
Android Studio practice
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1"
android:layout_marginLeft="10pt"
android:layout_marginRight="10pt"
android:layout_marginTop="3pt">
<EditText
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="5pt"
android:id="@+id/etNum1"
android:layout_width="match_parent“
android:inputType="numberDecimal">
55 </EditText>
<EditText
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5pt"
android:id="@+id/etNum2"
android:layout_width="match_parent"
android:inputType="numberDecimal">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_marginTop="3pt"
android:layout_marginLeft="5pt"
android:layout_marginRight="5pt">
<Button android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="+“ android:textSize="8pt"
56
android:id="@+id/btnAdd">
</Button>
<Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="-"
android:textSize="8pt"
android:id="@+id/btnSub">
</Button>
<Button
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="1"
android:text="*"
android:textSize="8pt"
android:id="@+id/btnMult">
</Button>

57
<Button
android:layout_height="wrap_conten
t"
android:layout_width="match_parent
"
android:layout_weight="1"
android:text="/"
android:textSize="8pt"
android:id="@+id/btnDiv">
</Button>
</LinearLayout>
<TextView
android:layout_height="wrap_content
"
android:layout_width="match_parent"
android:layout_marginLeft="5pt"
android:layout_marginRight="5pt"
android:textSize="12pt"
android:layout_marginTop="3pt"
android:id="@+id/tvResult"
android:gravity="center_horizontal"
>
58
</TextView>
public class MainActivity extends Activity implements
OnClickListener {

EditText etNum1;
EditText etNum2;

Button btnAdd;
Button btnSub;
Button btnMult;
Button btnDiv;
TextView tvResult;
String oper = "";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// find the elements


etNum1 = (EditText) findViewById(R.id.etNum1);
59etNum2 = (EditText) findViewById(R.id.etNum2);
btnAdd = (Button) findViewById(R.id.btnAdd);
btnSub = (Button) findViewById(R.id.btnSub);
btnMult = (Button) findViewById(R.id.btnMult);
btnDiv = (Button) findViewById(R.id.btnDiv);

tvResult = (TextView) findViewById(R.id.tvResult);

// set a listener
btnAdd.setOnClickListener(this);
btnSub.setOnClickListener(this);
btnMult.setOnClickListener(this);
btnDiv.setOnClickListener(this);

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float num1 = 0;
float num2 = 0;
float result = 0;

// check if the fields are empty


if (TextUtils.isEmpty(etNum1.getText().toString())
|| TextUtils.isEmpty(etNum2.getText().toString())) {
return;
}

60
// read EditText and fill variables with numbers
num1 = Float.parseFloat(etNum1.getText().toString());
num2 = Float.parseFloat(etNum2.getText().toString());

// defines the button that has been clicked and performs the operation
// write operation into oper, we will use it later for output
switch (v.getId()) {
case R.id.btnAdd:
oper = "+";
result = num1 + num2;
break;
case R.id.btnSub:
oper = "-";
result = num1 - num2;
break;
case R.id.btnMult:
oper = "*";
result = num1 * num2;
break;
case R.id.btnDiv:
oper = "/";
result = num1 / num2;
break;
default:
break;
}
// form the output line
tvResult.setText(num1 + " " + oper + " " + num2 + " = " + result);
}
61 }
OUTPUT

62
How to Start Mobile Application
Business

DEPLOYMENT AND PUBLISING OF


APPLICATION ON GOOGLE
ANDROID MARKET

63
The Android Market or the
Android central is known to be the
very own repository of Google for
Android applications.

64
Android Market recently renamed as
Google play is developed and
maintained by Google. It is an online
electronic store or digital application
distribution platform for android
powered devices.

65
The application developed by any
developer has to be tested before
it is uploaded to the Android
market to ensure that your app is
error and bug free.

66
The developer needs to register
before publishing the app with a
publisher account by visiting the
Google Play Developer console at
https://play.google.com/apps/
publish/.

67
TOOLS & MATERIALS NEEDED
FOR THE DEVELOPMENT

 THIS MATERIAL
 VIDEO TUTORIALS (ONLINE & OFFLINE)
 INTERNET
 GOOD BOOK (BEGINNER LEVEL IN MOBILE APP
DEVELOPMENT)
 HIGH CONFIGURATION LAPTOP WITH AT LEAST
4GB RAM
 ETC.

68

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy