What you can do in Android - Ning

knapsackyarnΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 4 χρόνια και 18 μέρες)

67 εμφανίσεις

What you can do in Android that
you can’t in iOS

How to build unique and compelling
apps that users want!

1

WHY SHOULD YOU EVEN CARE?

2

Because Android is eating every other
platform for breakfast

3

2.5X

of Apple’s
worldwide
shipment (Q1 2012)


~
50%

Of smartphone owners in
the US own an Android
phone (Q1 2012)


Because Android is popular for
certain segments


Hispanics


African Americans


Teens


Pre
-
Paid
smartphone users






4

More likely to own a
smartphone than
general population

One of the fastest
growing segments of
smartphone market

Because HTML applications still
kinda

suck

5

Because differentiation will make your
app stand out!


Clear



Path



Google Plus


6

WHAT YOU CAN DO IN ANDROID

Widgets

Navigation

Voice Input

Multitasking

Intents

Event Receivers

Open API’s


7

Widgets


Widgets are small applications that
can be placed directly on the home
page



Information conveyed in the widget
can be updated in the
background



You can also create live updating
backgrounds and shortcuts to specific
resources



Examples: Facebook, Pandora,
Beautiful Widgets


8

Widgets
-

Advantages


Easy to present information


No need to open app to see
info



Can poll for updates in the
background



Widgets are interactive!


Users can cycle through data


Users can update as well as
consume data


9

What could you do with Widgets?


Operational dashboard (on a phone
or tablet home screen)


C
urrent waiting time for United
customers


Total sales, top 10 items at Sears



Marketing: Track social activity for
today’s
Groupon




Approve or reject work items



Real
-
time bids on
TaskRabbit


10

Navigation


Apple users have the Map app but
no built
-
in navigation app



Android offers a more convenient
alternative


Turn
-
by
-
turn directions from any
location on the map


Directions can be fired from any geo
-
location



Examples: Google Places

11

Navigation
-

Advantages


Skip directly to directions
without having to go to a
map



Ideal for drivers, where user
interaction and clicks need
to be limited


12

What could you do with Navigation?


Social navigation


My friend is at
Hopleaf



get
me there by CTA!



Navigation tied to inventory


Directions to the nearest Best
Buy with Diablo 3


Directions to the nearest
Redbox with the Muppets
Movie


13

Voice Input


Apple features the well
-
known
Siri
, but does not offer any
developer integration into the
tool



On Android, developers can
implement voice input via
code



Examples: Google Voice
Actions, Assistant


14

Voice Input


Advantages


Ideal when users cannot
concentrate on the screen
(i.e. driving or walking)



Increased safety


users can
keep their eyes up while
walking or driving



Shortcut applications with
multiple input fields


15

What can you do with Voice Input?


Add voice to directions
-
based applications


“Take me to the nearest
Redbox with The Muppets
Movie”



Travel Reservations


“Find me a hotel in
Chicago from June first to
June fifth”


16

Multitasking


Apple background processes are
limited to location services, audio, or
VoIP



iOS has push notification, which are
also limited:


The notification has to be registered
with Apple, with all the headaches that
entails



Android has true multi
-
tasking services
without requiring registration with a
central authority



Examples:
Tasker
, Chrome to Phone


17

Multitasking
-

Advantages


Android’s multitasking allows the
application to run true background
processes



Android allows services to get third
party updates without registering
with a central server



This capability also allows the
application to run long
-
lived
activities after you leave the app
(such as uploading a picture)


18

What can you do with Multitasking?


Operational widget: update
operational widget in the
background



Context
-
sensitive applications:
perform actions in the
background based on time of day,
location, etc



Send an SMS or email from your
application (and return back)


19

Intents


iOS has document interactions, which
are meant for viewing or editing
documents



Android intents allow developers to
define an event to which another
application will respond



Intents can respond to a specified
action, and filter based on URL
scheme and mime type



Examples: Maps, Barcode Scanner,
Open Table


20

Intents
-

Advantages


Easily leverage device functionality
like SMS, email, camera and
telephony



Create applications to be callable



Call other applications on the
phone with less effort and without
using server
-
side code



Other developers can leverage the
code without packing API libraries,
reducing application size and
download time


21

What can you do with Intents?


Create an callable API as
part of the overall
application strategy



Create an
Orbitz

application
with intents to allow other
applications to book a flight


22

Event Receivers


The Android OS broadcasts events
on system conditions such as
receiving an SMS or initiating a call



Developers can create event
receivers


classes which are
instantiated for specific intents



Event receivers can perform filtering
beyond intent type and only
intercept the events they want



Examples: SMS, Camera Apps


23

Event Receivers
-

Advantages


Developers can integrate
with phone system events



There is no need to create
polling operations


the OS
will forward events to any
appropriate receivers



Events are broadcast;
multiple receivers can act on
the same event based on
priority


24

What can I do with Event Receivers?


Calling applications:
intercept international
calls and route to a calling
card number



SMS applications:
intercept and auto
-
reply to
messages from select
users


25

Rich API


Android offer the ability to change
almost all aspects of the phone, like:



Bluetooth: turn Bluetooth on/off, scan for
devices, establish connection



Wifi
: turn
wifi

on/off, scan for networks,
establish connection



USB: establish connections to a device as a
host or accessory (available as an additional
library in Gingerbread)



NFC: act as an NFC initiator or reader;
trigger an activity on read receipt


26

Rich API
-

Advantages


Capability to integrate with
almost anything they can
imagine!



Core applications and API’s
are public
-

developers can
easily extend existing
functionality


27

What can I do with the API?


Dictionary updates: update
dictionary with medical, legal,
or government terminology



Build proximity
communication apps in
Bluetooth or NFC



Build a better home screen,
notifications toolbar, or phone
dialer


28

Just because you can doesn’t mean
you should


Don’t create needless
background processes that kill
battery life or eat bandwidth!



Don’t hijack events and break
normal system usage!



Don’t modify standardized
tools or inherit system API’s
without a good reason!

29

iOS applications have great user
interface, but…


However, Android
applications are more
feature
-
rich in many
other areas
-


Background processing


Cross
-
app
communications


Rich interaction from
the home screen with
widgets


Phone integration


30

Android

Multi
-
tasking

Cross
-
app calls

Widgets

NFC

Rich
system
APIs

Just remember…

31

“We don’t need any
more fart apps”

Build something better!

Steve Jobs, 9/9/2010

Questions?

32

joe.nedumgottil@parivedasolutions.com

LinkedIn:

http
://www.linkedin.com/in/jnedumgottil

Google Plus:
https://plus.google.com/u/0/111620262743668206893

APPENDIX: CODE SAMPLES

33

Widgets

34

Reference:


http://developer.android.com/guide/topics/appwidgets/index.html

Define the widget in Manifest.xml:

<receiver
android:name
="
ExampleAppWidgetProvider
" >





<intent
-
filter>









<action
android:name
="
android.appwidget.action.APPWIDGET_UPDATE
" />





</intent
-
filter>





<meta
-
data
android:name
="
android.appwidget.provider
"
















android:resource
="@xml/
example_appwidget_info
" />

</receiver>

Define App Widget Provider Info:

<
appwidget
-
provider
xmlns:android
="http://schemas.android.com/
apk
/res/android"





android:minWidth
="294dp"





android:minHeight
="72dp"





android:updatePeriodMillis
="86400000"





android:previewImage
="@
drawable
/preview"





android:initialLayout
="@layout/
example_appwidget
"





android:configure
="
com.example.android.ExampleAppWidgetConfigure
"





android:resizeMode
="
horizontal|vertical
">

</
appwidget
-
provider>

Widgets

35

Reference:

http
://developer.android.com/guide/topics/appwidgets/index.html

Widget Class:

public class
MyAppWidgetProvider

extends
AppWidgetProvider

{






public void
onUpdate
(Context
context
,
AppWidgetManager

appWidgetManager
,
int
[]

appWidgetIds
) {









final
int

N =
appWidgetIds.length
;










// Perform this loop procedure for each App Widget that belongs to this provider









for (
int

i=0; i<N; i++) {













int

appWidgetId

=
appWidgetIds
[i];














// Create an Intent to launch
ExampleActivity













Intent
intent

= new Intent(context,
ExampleActivity.class
);













PendingIntent

pendingIntent

=
PendingIntent.getActivity
(context, 0, intent, 0);














// Get the layout for the App Widget and attach an on
-
click listener













// to the button













RemoteViews

views = new
RemoteViews
(
context.getPackageName
(),




R.layout.appwidget_provider_layout
);













views.setOnClickPendingIntent
(
R.id.button
,
pendingIntent
);














// Tell the
AppWidgetManager

to perform an update on the current app widget













appWidgetManager.updateAppWidget
(
appWidgetId
, views);









}





}

}

Navigation

36

Reference:


http://stackoverflow.com/questions/5801684/intent
-
to
-
start
-
a
-
navigation
-
activity

Call Navigation:

public void
callNav
() {


String
latLong

= "41.88,
-
87.64";


Intent i = new Intent();


i.setAction
(
Intent.ACTION_VIEW
);


i.setData
(
Uri.parse
("
google.navigation:q
=" +
latLong
));


startActivity
(i);

}

Voice Input

37

Reference:


http
://developer.android.com/resources/samples/ApiDemos/src/com/example/
android/apis/app/VoiceRecognition.html

Call Voice Recognition:

private void
startVoiceRecognitionActivity
() {


Intent
intent

= new Intent(

RecognizerIntent.ACTION_RECOGNIZE_SPEECH
);


intent.putExtra
(
RecognizerIntent.EXTRA_LANGUAGE_MODEL
,


RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
);


intent.putExtra
(
RecognizerIntent.EXTRA_PROMPT
, "Speech

recognition demo");






startActivityForResult
(
intent,VOICE_RECOGNITION_REQUEST_CODE
);

}

Voice Input

38

Reference:


http
://developer.android.com/resources/samples/ApiDemos/src/com/example/
android/apis/app/VoiceRecognition.html

Retrieve Voice Recognition results:

protected void
onActivityResult
(
int

requestCode
,
int

resultCode
,

Intent
data) {


if (
requestCode

== VOICE_RECOGNITION_REQUEST_CODE &&


resultCode

== RESULT_OK) {




// Fill the list view with the strings the recognizer thought it


// could have heard




ArrayList
<String> matches =
data.getStringArrayListExtra
(


RecognizerIntent.EXTRA_RESULTS
);


mList.setAdapter
(



new
ArrayAdapter
<String>(this,






android.R.layout.simple_list_item_1,






















matches));




}


super.onActivityResult
(
requestCode
,
resultCode
, data);

}

Multi
-
tasking

39

Reference:

http
://developer.android.com/guide/topics/fundamentals/services.html

Initiate a service to handle Intents in the background:

public class
MyIntentService

extends
IntentService

{




public
MyIntentService
() {







super("
MyIntentService
");



}



/**




* The
IntentService

calls this method from the default worker


* thread with the intent that started the service. When this


* method returns,
IntentService

stops the service, as


* appropriate.




*/


protected void
onHandleIntent
(Intent intent) {







if(
intent.getAction
().
equalsIgnoreCase
(
My_Intent
)){


// do something


}



}

}

Intent

40

Reference:

http://twidroyd.com/plugins
/

https://github.com/c99koder/lastfm
-
android/wiki/Activities

Call the
Twidroyd

“Twitter” intent:

public void
fireTweet
() {


Intent
sendIntent

= new Intent(
Intent.ACTION_SEND
);


sendIntent.putExtra
(
Intent.EXTRA_TEXT
, “My tweet”);


sendIntent.setType
("application/twitter");


startActivity
(
Intent.createChooser
(
sendIntent
, null));

}

Use Last.FM to retrieve artist info:

public void
getArtistInfo
() {


intent = new Intent(
Intent.ACTION_VIEW
);


intent.setComponent
(new
ComponentName
(


"fm.last.android","
fm.last.android.activity.Metadata
"));


intent.putExtra
("artist", “U2");


startActivity
( intent );

}

Event Receivers

41

Reference:


http://developer.android.com/reference/android/content/Intent.html

Intercept a call:

public class
CallReceiver

extends
BroadcastReceiver

{


public void
onReceive
(Context
context
, Intent intent){



if(
intent.getAction
().
equalsIgnoreCase
(



Intent.ACTION_NEW_OUTGOING_CALL
)){



// do something


}


}

}

Open API’s

42

References:


http://ishouldhaveknownthisbefore.wordpress.com/2011/01
/

http://
developer.android.com/guide/topics/wireless/bluetooth.html

http
://android.git.kernel.org
/

http://
developer.android.com/

Turn on Bluetooth:

public void
turnOnBluetooth
() {


BluetoothAdapter

bt

=
BluetoothAdapter.getDefaultAdapter
();



if (!
bt.isEnabled
()) {


bt.enable
();


}

}