• Tidak ada hasil yang ditemukan

Multimedia Mobile Programming Pertemuan 9

N/A
N/A
Protected

Academic year: 2019

Membagikan "Multimedia Mobile Programming Pertemuan 9"

Copied!
25
0
0

Teks penuh

(1)

Android GUI

Project

(2)

Android

1. Android Basics

2. Android Development

3. Android UI

4. Hello, World

(3)

Android Basics

Open source OS

Uses Linux kernel

Optimized for limited-resource environment

Apps typically written in Java

Apps run on the Dalvik Virtual Machine

Not a JVM, but works similarly from

developer’s point of view

Usually one app per DVM

Each DVM runs under Linux as a separate

user

App permissions set at install time

Possible to use C or C++ compiled to machine

code, but still runs on VM. It’s not clear to me how this works.

Docs say it does not necessarily improve

(4)

Sams Teach Yourself Android™Application Development in 24 Hours (0321673352)

Copyright ©2010 Lauren Darcey and Shane Conder

(5)

Android Development

Well-defned framework for app

development

Apps are typically coded using Java

syntax, but other parts of the Java

platform are missing

Some standard Java SE or ME APIs and

class libraries are not included

(6)

Android Development

Standard development environment is Eclipse

+ Android Development Tools plugin + Android SDK

Development requires either an Android OS

device or an emulator

Emulator has limitations:

• Performance is poor

• Camera, etc., simulated using your computer’s hardware

• No real phone calls or texts

• GPS data, battery readings, etc. must be simulated

Real device is afected by specifc hardware

(7)

Android vs. Other

Mobile OS

I was able to choose what kind of smart phone to get according to which platform I wanted to use to try mobile development

Android:

I had Java backend code ready to go for a frst

project

Interesting platform:

Familiar programming environmentCurrently the market leader

Broad market, unlike more focused iOS,

Blackberry, and (Palm) webOS

Development tools are open source and are

(8)

Android App vs. Mobile- Optimized

RIA

Android Flash plugins available; Silverlight

coming soon

Could develop in JavaScript and/or HTML5

WWW App

Easier for users to run; no need to installFor a paid app, avoid the 30% App Store

commission

Easier to write cross-platform apps

Android Apps

Fewer security hurdles

Use APIs for access to built in GPS, camera,

etc.

(9)

Android Apps: Marketing

Usually market apps through Android App Market

There are other markets, also

App store will dominate the market due to

access through built in app

Can set up for download directly on a website

User must agree to “install apps from unknown

(10)

Android Apps: Marketing

Revenue from app sales prices and/or advertising

Conventional wisdom is that iOS users will pay

for apps, but Android users won’t

57% of Android App Store apps are free, vs.

28% for Apple App Store

Android Market takes 30% commission

Any purchase model other than one-time

purchase must be homegrown, using Paypal or similar service

PPC ads

My guess is that response to these is

extremely low

Probably need to be very aggressive with

banner ads

(11)

Android Deployment

Apps are packaged in .apk format,

variant of .jar, then downloaded to

device and installed

.apks contain .dex fles (bytecode),

manifest and various other fles

Manifest contains security and link

(12)

Android UI

Activity: single screen with a UI, somewhat

analogous to XAML / code behind pattern in .NET

Email app might have one activity that

shows a list of new emails, another activity to compose an email, and another activity for reading emails

Implement by subclassing Activity class

View: drawable object

Android UI View

MVC View

UI contains a hierarchy of Views

View is a class, subclassed by the drawable

(13)

Android UI

Service: background operation

play music in the background while the

user is in a diferent application

fetch data over the network without

blocking user interaction with an

activity

Content Provider: DB or other data access

Broadcast Receiver: responds to system

messages

(14)

Android UI

UI construction can be done in three

ways:

Programmatic, like hand-coded Java

desktop GUI construction

Declarative hand-written, like Java web

UI construction

XML

Declarative with a GUI builder, like .NET

UI construction

(15)

Programmatic UI

package cs454.demo;

import android.app.Activity;

import android.widget.TextView; import android.os.Bundle;

public class AndroidDemo extends Activity {

/** Called when the activity is frst created. */ @Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Activity is a subclass of context, so the TextView takes this as a parameter TextView tv = new TextView(this);

tv.setText("Hello, CS454"); setContentView(tv);

(16)

Manual Declarative

UI

main.xml Layout File:

<?xml version="1.0" encoding="utf-8"?>

<TextView

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/textview"

android:layout_width="fll_parent"

android:layout_height="fll_parent"

android:text="@string/hello"/>

strings.xml resource fle:

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="hello">Hello Again, CS454!</string>

<string name="app_name">CS454 AndroidDemo</string>

(17)

Manual Declarative

public class AndroidDemo extends Activity {

/** Called when the activity is frst created. */ @Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

(18)

What’s R?

/* AUTO-GENERATED FILE. DO NOT MODIFY. This class was automatically generated by the

* aapt tool from the resource data it found. It should not be modifed by hand. */

package cs454.demo; public fnal class R {

(19)
(20)

Android Event

Handlers

From the code fle for the activity:

Button ok = (Button) fndViewById(R.id.button1);

ok.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {

CharSequence s = et.getText(); tv.setText("Welcome, " + s);

(21)

Sams Teach Yourself Android™Application Development in 24 Hours (0321673352)

Copyright ©2010 Lauren Darcey and Shane Conder

(22)

APIs for Android built-ins

Android OS ships with many built in apps

Web Browser

Google Maps

Navigation

Camera apps

Built in access for these as well as TTS

(23)
(24)

My Project

Goats and Tigers is a board game, which we

implemented in Java in CS 460 last term.

The objective in CS460 was to implement the

minmax / alpha beta pruning algorithm for the automatic player, not to create a good UI

My existing interface shows an ASCII art picture

of the board and provides a JOptionPane menu of available moves

I will develop an Android UI and use my existing

(25)

References

http://www.ibm.com/developerworks/opensource/library/os-android-devel/

http://developer.android.com/resources/browser.html?

tag=tutorial

Conder and Darcey, Android Wireless Application

Development, Addison-Wesley, 2010

Conder and Darcey, Sams Teach Yourself Android

Gambar

FIGURE 5.6 Simplifed Android platform architecture from a security perspective.
FIGURE 3.2 Important callback methods of the activity life cycle.

Referensi

Dokumen terkait

Alifatun Qoyyimah yang selalu ada untuk memberikan semangat, kritik dan saran bagi penulis, Nandya Diva Onawa dan Virginia Fadillah yang memperkenalkan penulis pada drama

Kedua Kisi-kisi ini disajikan dengan maksud memberikan informasi mengenai butir-butir yang didrop setelah dilakukan uji validitas, uji reliabilitas serta analisis butir

Hubungan Antara Lingkungan Fisik Sekolah Dengan Motivasi Belajar Pada Siswa di SMK Gita Kirtti 2 Jakarta, Skripsi, Jakarta : Konsentrasi Pendidikan Administrasi Perkantoran, Program

Tabel 4.183 Nilai Kecepatan sistem Variabel Kepentingan Human Resource Stream 156. Tabel 4.184 Nilai Informasi yang up-to-date Variabel Kepentingan

Sampel ulat sagu yang dikeringkan pada temperatur 50°c dengan menggunakan oven selama 1 jam menunjukkan 21 pita, memiliki 4 pita protein mayor dan 17 pita protein

At the level of the central government has no National Research Council, it is appropriate that the Regional Government of West Sumatra Province to establish a Regional

Dengan rendah hati, penulis memanjatkan puji syukur atas berkat rahmat yang dilimpahkan Tuhan Yang Maha Esa, sehingga penulis dapat menyelesaikan penulisan skripsi yang

Sosial ekonomi yang rendah dapat meningkatkan risiko kejadian stunting pada anak, adapun faktor sosial ekonomi ini meliputi : pendapatan rumah tangga rendah (kemiskinan),