Top Banner
Subhead (Arial, U/L, 18pt) Lori Fraleigh Director Developer Platforms, Tools, and Technical Services BUSINESS UNIT NAME (Arial Bold, Caps, 24pt) MOTOROLA and the Stylized M Logo are trademarks or registered trademarks of Motorola Trademark Holdings, LLC. All other trademarks are the property of their respective owners. © 2010 Motorola Mobility, Inc. All rights reserved.
44

Using the Motorola MOTODEV i1 SDK add-on

May 22, 2015

Download

Technology

this presentation covers how to use the i1 SDK add-on now available on developer.motorola.com
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using the Motorola MOTODEV i1 SDK add-on

Subhead (Arial, U/L, 18pt)

Lori FraleighDirectorDeveloper Platforms, Tools, and Technical Services

BUSINESS UNIT NAME (Arial Bold, Caps, 24pt)

MOTOROLA and the Stylized M Logo are trademarks or registered trademarks of Motorola Trademark Holdings, LLC. All other trademarks are the property of their respective owners. © 2010 Motorola Mobility, Inc. All rights reserved.

Page 2: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

starts hereLEADERSHIP

Page 3: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DEVELOPDESIGN DISCOVER DISTRIBUTE

Page 4: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DESIGN

DETAILED PRODUCTINFORMATION AND SPECS

PRACTICAL ADVICE,ARTICLES, DOCUMENTATION

EXPERT SUPPORT, FORUMS, KNOWLEDGE BASE

COMMUNITY INTERACTION,BLOGS, PODCASTS

GLOBAL NEWS, EVENTSAND TRAINING

Page 5: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DESIGNDESIGN DEVELOP

GREAT OUT-OF-BOX EXPERIENCE

BUILT ON ECLIPSE

ACTIVITY CREATION WIZARDS

CODE SNIPPETS

IMPROVED LOCALIZATION TOOLS

DEVICE EMULATORS

Page 6: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DESIGN DEVELOP

REMOTE ON-DEVICE TESTING

ACCESS TO LIVE REGIONAL NETWORKS

EARLY ACCESS – GET TO MARKET FIRST

Page 7: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DISCOVERDESIGN DEVELOPDEVELOP

EARLY ACCESS TO TOOLS,SDKS, SPECS, ARTICLES

PRIVATE DISCUSSION BOARDS

ACCESS TO PRE-RELEASE HARDWARE

PREMIUM RESOURCES FROM WORLD-CLASS PROVIDERS

Page 8: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

DESIGN DEVELOP DISCOVER DISTRIBUTE

APP SUBMISSION INTEGRATEDINTO MOTODEV

INTEGRATED TESTINGAND CERTIFICATION

TARGETED MERCHANDISINGAND PROMOTIONS

EFFECTIVELY SHOWCASEAND SELL YOURSIGNATURE APPS

Page 9: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

WE ARE INVESTING IN YOUR FUTURE

Page 10: Using the Motorola MOTODEV i1 SDK add-on

Anna Schaller Android AdvocateDeveloper Community Technical Services

Motorola Mobility

MOTOROLA and the Stylized M Logo are trademarks or registered trademarks of Motorola Trademark Holdings, LLC. All other trademarks are the property of their respective owners. © 2010 Motorola Mobility, Inc. All rights reserved.

Using the Motorola i1 SDK Add-On

Page 11: Using the Motorola MOTODEV i1 SDK add-on

Agenda

00 Motorola i1 SDK Add-on Walkthrough

00 Working with the iExchange Service01 Architecture02 Using Intents to pass messages03 Demo

00 Content Provider Extensions01 Contacts02 CallLog03 MOTODEV Studio Database Explorer

© 2010 Motorola Mobility, Inc.

Page 12: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Using the i1 SDK Add-On

• Motorola i1 is based on Android 1.5– i1 SDK add-on uses Android SDK 1.5 APIs

• Setting up development environment– Install in add-ons folder within Android SDK– Create a new projects from samples– Create an AVD emulator for Motorola i1– Bring up Motorola i1 emulator

Page 13: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Create Development Environment

1. Install in add-ons folder within Android SDK

Page 14: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Create Development Environment (con’t)

a) Importing them File -> Import -> Existing Projects in

Workspace Browse to

/add-ons/Motorola i1/samples folder

b) Create New Project from samples

2. Pull in iExchange Samples

Page 15: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Create Development Environment (con’t)

• Two new projects– iExchangeSender– iExchangeReceiver

• Two new libraries– motorola.provider.jar– iexchangelib.jar

Page 16: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Create Development Environment (con’t)

3. Create i1 AVD

– Select Motorola i1 APIs as target

Page 17: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Create Development Environment (con’t)

4. Bring up emulator

Page 18: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Working with the iExchange Service

• Allows messages to be dispatched between devices using the PTT protocol– Takes advantage of empty frames of talk time for passing

data

• Three kinds of dispatch ids supported– Private Id : 1-to-1 communication– Group Id: 1-to-many communication– SDG Id: Selective Dynamic Group Call

Page 19: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Architecture

• Components at every layer of Android to support functionality

• Engine – lowest level handles communication at RIL

• Background Service – framework level handles communication between

engine and application

• Android application – takes input from the user and broadcasts the message

using the iExchange library

Page 20: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Initialization • When device starts up,

iExchange service registers with iExchange engine and waits….

Package Manager

Content Provider

<…>

iExchangeService

iExchangeEngine network

BP layer

Framework layer

App

Application layer

• iExchange engine determines whether the phone is connected to the network and returns a connected state to iExchange service

• Once iExchange service receives connected state, registers for message intents and waits on broadcast from iExchange apps….

Page 21: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Communication

• Uses standard Android mechanisms already in place• Activities, services, and broadcast receivers are activated

through structured messages embedded in an Intent– Intents are used throughout Android for system-level

message passing (low battery, screen on, time zone change)

– Intents are also used in Android to launch another activity, service, or broadcast receiver

– Once launched those activities, services, and broadcast receivers can receive message intents while they are running

Page 22: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Communication (con’t)

• Anatomy of an Intent– Action: action to be performed or the action that took place and is

being reported (broadcast intents)

– Category: always set to CATEGORY_DEFAULT

– Extras: additional information (including data)

• Intents are delivered in one of three ways:– startActivity(intent) launches an Activity -- if not already

started -- and delivers the embedded message– startService(intent) launches a Service -- if not already

started -- and delivers the embedded message– sendBroadcast(intent) launches a Broadcast Receiver and

delivers the embedded message

Page 23: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Writing an iExchange App

• import com.motorola.android.ptx.IexchangeConstant;

• iExchange library (iexchangelib.jar)– Request Intents: initiates action– Response Intents: returns success or failure of action

request– Indication Intents: indicates message was sent– Permissions: for sending and receiving

• Communication requires two modes– Message Sender (iExchangeSender sample)– Message Receiver (iExchangeReceiver sample)

Page 24: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Writing an iExchange App (con’t)

• Standard Android app with two tasks

• Main task – runs in UI thread

– extends Activity class

– broadcasts outbound messages through iExchange intents

– does something with incoming message

• Secondary task – extends Broadcast Receiver class

– processes incoming iExchange intents

Activity

Broadcast Receiver

Page 25: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Dispatching Messages

Sending Activity

Broadcast Receiver

iExchangeService

request intent

response intent

iExchangeService

Receiving Activity

Broadcast Receiver

iExchangeSender (phone 1)

iExchangeReceiver (phone 2)

response intent

request intent

indication intent

Page 26: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Request Intents• Action

– ACTION_SEND_IEXCHANGE_PRIVATE_TEXT_MESSAGE– ACTION_SEND_IEXCHANGE_PRIVATE_DATA_MESSAGE– ACTION_SEND_IEXCHANGE_GROUP_TEXT_MESSAGE– ACTION_SEND_IEXCHANGE_GROUP_DATA_MESSAGE

• Extra Data– String DESTINATION_ADDR (Push-To-Talk Id - private)

– int LOCAL_PORT (Sender Port Identifier)

– int REMOTE_PORT (Receiver Port Identifier)

– String GROUP_NUMBER (Group Call ID - group)

– String AREA (Group Call Area - group)

– String TEXT (Message)

– byte[] DATA (Data)

• Category– CATEGORY_DEFAULT

Page 27: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Indication Intent

• Extra Data– byte IND_DATA_TYPE (Data type – ‘T’ext or

‘B’inary)– int IND_DATA_LENGTH (Length of data)– byte[] IND_DATA (Data message)– int IND_DATA_REMOTE_PORT (Sender’s Port Identifier)

• Action– ACTION_IEXCHANGE_MESSAGE_RECEIVED

• Category– CATEGORY_DEFAULT

Page 28: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

iExchange Response Intent• Action

– ACTION_IEXCHANGE_RESPONSE

• Category– CATEGORY_DEFAULT

• Extra Data– int RSP_IEXCHANGE_REQ_TYPE (SEND_PRIVATE_TEXT_MESSAGE)

(SEND_PRIVATE_DATA_MESSAGE)

(SEND_GROUP_TEXT_MESSAGE)

(SEND_GROUP_DATA_MESSAGE)

– byte RSP_IEXCHANGE_RESULT (RESULT_RESERVED)

(RESULT_SUCCESSFUL)

(RESULT_ERROR_INVALID_ID)

(RESULT_ERROR_MESSAGE_TOO_LONG)

(RESULT_ERROR_GENERIC_FAILURE)

(RESULT_IN_PROGRESS)

Page 29: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

New Permissions

• RECEIVE_IEXCHANGE – Allows the application to receive iExchange Response and

Indication Intents

• SEND_IEXCHANGE – Allows the application to send iExchange Request Intents

<uses-permission android:name="com.motorola.android.iexchange.permission.RECEIVE_IEXCHANGE"></uses-permission>

<uses-permission android:name="com.motorola.android.iexchange.permission.SEND_IEXCHANGE"></uses-permission>

Page 30: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Code and Demo

Page 31: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

HEADLINE (Arial Bold, Caps, 24pt)

Place audio or video here

Page 32: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Content Providers• Generic interface mechanism that lets you share data

between applications • By abstracting away the underlying data source,

Content Providers let you decouple your application layer from the data layer, making your applications data-source agnostic

• How a content provider actually stores its data under the covers is up to its designer

• All content providers implement a common interface for querying the provider and returning results

Page 33: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Content Providers• Many of the native databases have been made

available as Content Providers, accessible by 3rd party applications

• Built-in Content Providers available to you:– Browser– CallLog– Contacts– MediaStore– Settings

• Motorola i1 extends the Contacts and CallLog Content Providers (and underlying tables)

Page 34: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Content Resolvers

• Access to all Content Providers is handled through ContentResolver objects calling getContentResolver()

<. . .>

ContentResolver cr = getContentResolver();

<. . .>

• Can then use ContentResolver’s methods– query() – insert()– delete()

Page 35: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Queries and Cursors• Queries in Android are returned as Cursor objects• Cursors are a managed way of controlling your position

(row) in the result set of a database query• To execute a query…call query()

ContentResolver cr = getContentResolver();Cursor myCursor = cr.query(Uri, // data set (e.g. table(s))projection, // include table columnswhere clause, // filter out rowsselection, // data for where ‘?’sort order // sort in order

)

• Navigate query results with moveTo<position>()

Page 36: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

URIs

• Each content provider exposes a public URI that uniquely identifies its data set

• A content provider that controls multiple data sets (multiple tables) exposes a separate URI for each one

• Two forms:– All URIs for providers begin with the string "content://"

– Android defines CONTENT_URI constants for all the providers that come with the platform

android.provider.Contacts.Phones.CONTENT_URI

android.provider.CallLog.Calls.CONTENT_URI

• Use both forms when working with the SDK add-on depending on what data set you need

Page 37: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

i1 Extensions - Contacts• Access

– Generic URI is People.CONTENT_URI– import android.provider.Contacts.People

– Iden URIs now join multiple tables together– import motorola.provider.ContactsIdenExtensions

• Tables– Two new tables IDENDISPATCHES (dispatch numbers) and

IDENIP (ip address)

– Existing PEOPLE table extended with 3 new fields• iden_contact_type (private id vs group id vs sdg id)

• iden_member_count (member count of sdg entry)

• iden_primary_dispatch (link to idendispatch table)

Page 38: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

i1 Extensions – Contact URIs

• iDEN-specific Contacts URI’s– "content://contacts/people-sdg“– "content://contacts/people-talkgroup“– "content://contacts/idendispatches“– "content://contacts/idendispatches/#“– "content://contacts/people/#/idendispatches“– "content://contacts/people/#/idendispatches/#“– "content://contacts/idendispatches/filter_name/*“– <. . .>

• Check documentation to find out what data set is available to build you projection

Page 39: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Using iDEN URIsfinal String[] PROJECTION = new String[] {

People._ID, People.NAME,

PeopleIdenExtensionsColumns.PRIMARY_DISPATCH_ID, PeopleIdenExtensionsColumns.CONTACT_TYPE,

IdenDispatches.NUMBER,

IdenDispatches.TYPE,

IdenDispatches.LABEL

};

ContentResolver cr = getContentResolver();

Cursor c = cr.query(Uri.parse("content://contacts/idendispatches"), PROJECTION, null , null, null );

Page 40: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

i1 Extensions - CallLog• Access

– Generic URI is Calls.CONTENT_URI – import android.provider.CallLog.Calls.CONTENT_URI

– CallLog URIs join multiple tables together– import motorola.provider.CallLogIdenExtensions

• Tables– Call log is stored in contacts database in the CALL table

– New fields added to existing table• Idencategory (phone call vs dispatch vs ptx attachment)• Idennumber (dispatch ptt number)• Idensubtype (subtype of dispatch – private, talkgroup, etc)• Ipaddress (ip address)• Membercount (member count of SDG entry)

Page 41: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

MOTODEV Database Explorer

• Gives you a window into Android databases

• Allows you to examine and modify the contacts database

• Only works on emulator, does not work on devices

• Let’s see……

Page 42: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

CONTACTS

• Join developer program at developer.motorola.com– MOTODEV Studio– Product SDK Add-Ons– Technical Articles– Developer Forum– Product Specs– More……

Page 43: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

Device Giveaway

• Under 40 seats in this room is an i1 postcard

• If you find a postcard, bring it and your business card to booth #23 between 6:30 and 9:30 tonight

• Employees of Motorola, Sprint, or any competitor of Motorola are not eligible to win.

Page 44: Using the Motorola MOTODEV i1 SDK add-on

Working with the Motorola i1 SDK Add-On

© 2010 Motorola Mobility, Inc.

LEGAL

• Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

• Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.