![Page 1: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/1.jpg)
See Androids Fighting
Dr. Holger Kremmin Program Architect [email protected] @kremminh
Integrating your Android Wear Watch with Salesforce
![Page 2: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/2.jpg)
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Safe Harbor
![Page 3: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/3.jpg)
Objectives In this session you will learn about:
§ Anatomy of an Android Wear Application
§ Integration Options
§ Leveraging Salesforce Mobile SDK for Android
§ How to setup your Android Studio Project
§ Leverage Example Code
After this session you should have a good understanding to quickly create a stunning Salesforce Android Wear application
![Page 4: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/4.jpg)
Not covered In this session you will not learn :
§ Oauth
§ Android application architecture
§ The Salesforce Rest API
§ Devolping for an Apple Watch …
Change pic
![Page 5: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/5.jpg)
Agenda § Architectural Overview
§ Prerequisites
§ Bridged Notifications
§ Data API
§ Q & A
![Page 6: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/6.jpg)
The Architecture of Android Wear
![Page 7: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/7.jpg)
Architectural Overview – Android Wear
Message API
Data API
Node API
Wearable App
Companion App
Awesome Companion App
Play Services
Wearable App
intents Awesome App
Android OS
Android W OS
Wearable App
![Page 8: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/8.jpg)
UI Building Blocks - Android Wear is different! Users are used to tapping icons to launch apps. A typical Wear app adds a card to the stream at a contextually relevant moment. It might have a button that opens a full screen view, but it just as well might not.
Contextual card Full Screen UI Watch Face
§ Bridged Notifications (no development on Wear Device!)
§ Contextual Notifications
§ 2D Picker
§ Custom Layouts
§ Custom Watch Face designs
![Page 9: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/9.jpg)
Salesforce Mobile SDK
Push Notifications Container Wrappers Files MDM Policies
Enterprise Identity & Security
SmartStore Encrypted Database
SmartSync Data Management
OS UI Frameworks Any Web Framework
SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), DreamActivity.class);
SalesforceSDKManager.getInstance().setPushNotificationReceiver(new TravelPushNotification(this));
public class DreamActivity extends SalesforceActivity {
![Page 10: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/10.jpg)
Architectural Overview – Salesforce Integration using GCM
Connected App Companion App
Notifications
Internet Internet
![Page 11: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/11.jpg)
Architectural Overview – Direct Integration using REST-API
Internet
Message API
Data API
Node API
![Page 12: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/12.jpg)
Prerequisites What you need to do upfront
![Page 13: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/13.jpg)
Setting Up Google Cloud Messaging (GCM) Get a new configuration at developer.google.com (Developer account required)
123456789012
ABC123JKL4567fyzu89012hjr
What you get: • Package Name • Server API Key • Sender ID
Com.dreamforce
![Page 14: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/14.jpg)
Configure the Connected App in Salesforce
At least a Developer Org & Admin rights required
from Google
![Page 15: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/15.jpg)
A lot of keys...What goes Where? Key Source Destination Server API Key Google Developer Salesforce Connected App
-> Mobile App Settings -> Key for Server Applications (API Key)
Sender ID Google Developer Resource File: <string name="androidPushNotificationClientId"> 123456789012 </string>
Android Package Name Google Developer Resource File: <string name="app_package">com.example.app </string>
Consumer Key Salesforce Resource File: <string name="remoteAccessConsumerKey"> 3MVG9xOCXq... </string>
![Page 16: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/16.jpg)
Setting Up Android Studio
§ Usage of Android Studio is highly recommended
§ Create a Library project for the Mobile SDK so you can reference it easily from your projects
§ Good Practice: Shared project for constants, resources etc.
§ Gradle as Build System
§ Use real devices for debugging instead of using Emulators
![Page 17: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/17.jpg)
The Notification API Bring your approval process to your Smart Watch
Demo
![Page 18: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/18.jpg)
Sample Workflow
Create Travel Request
Salesforce
Appex Trigger: Approval Process
Appex Trigger: Push Notification
GCM: Push Notification
Mobile Phone: Push Notification
Wear: Notification Cards
GCM Mobile Phone
Wear Device
Wear: Approve / Reject
Mobile Phone: Send Notification
GCM: Send Notification
Approve/ Reject
![Page 19: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/19.jpg)
Apex Code Snippet – Create & Send Notification/ Message // send the notification Messaging.PushNotification msg = new Messaging.PushNotification();
Map<String, Object> payload = new Map<String, Object>();
payload.put('ownerName', owner.Name); payload.put('ownerFullPhotoUrl', owner.FullPhotoUrl); ... msg.setPayload(payload);
// The approver's Id String userId = result.actorIds[0]; Set<String> users = new Set<String>(); users.add(userId);
msg.send('Android_Wear', users);
Create Message Object
Create Payload
Add Payload to Message
Add target Users
Send Message to target Users
![Page 20: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/20.jpg)
Implement PushNotificationInterface
PushNotificationInterface is a Mobile SDK Android interface for handling push notifications. PushNotificationInterface has a single method, onPushMessageReceived(Bundle message).
public class TravelPushNotification implements PushNotificationInterface { ... @Override public void onPushMessageReceived(final Bundle bundle) { ... //create an async task if you perform network tasks etc! Eg. Build your notification HERE
![Page 21: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/21.jpg)
Create Notifications with the Notification Builder The v4 support library allows you to create notifications using the latest notification features such as action buttons and large icons. To create a notification with the support library, you create an instance of NotificationCompat.Builder and issue the notification by passing it to notify()
// Main notification NotificationCompat.Builder mainNotification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.s1_icon) .setContentTitle(travelMessage.ownerName) .setContentText(“Travel approval required: " + travelMessage.travelName); ... // Open Card mainNotification.setContentIntent(openPendingIntent); NotificationManagerCompat.from(context).notify(1, mainNotification.build());
![Page 22: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/22.jpg)
Add Wearable Features For a Notification
If you ever need to add wearable-specific options to a notification, such as specifying additional pages of content or letting users dictate a text response with voice input, you can use the NotificationCompat.WearableExtender class to specify the options.
WearableExtender wearableExtender = new WearableExtender() .addAction(approveAction) .addAction(rejectAction) .addPage(detailNotification); mainNotification.extend(wearableExtender);
![Page 23: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/23.jpg)
Demo
23
![Page 24: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/24.jpg)
The Data API Sync your data between the Smart Watch and the Companion App
![Page 25: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/25.jpg)
Sample Workflow
Record Speech
Salesforce
Create DataItem Sync with Mobile
Sync with Wear Send Rest Object Show Chatter Post
GCM Mobile Phone
Wear Device
![Page 26: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/26.jpg)
The Wearable Data Layer API is part of Google Play services and provides a communication channel for your companion and wearable apps. The API supports the synchronization of data objects over the wire and eventing.
The Data API
A DataItem provides data storage with automatic syncing between the handheld and wearable. Asset objects are for sending binary blobs of data, such as images. You attach assets to data items and the system automatically takes care of the transfer for you, conserving Bluetooth bandwidth by caching large assets to avoid re-transmission.
WearableListenerService lets you listen for important data layer events in a service. The system manages the lifecycle of the WearableListenerService
DataListener lets you listen for important data layer events when an activity is in the foreground. Lets you listen for changes only when the user is actively using your app.
You can use the ChannelApi class to transfer large data items, such as music and movie files, from a handheld to a wearable device.
The MessageApi class can send messages and is good for remote procedure calls (RPC), such as controlling a handheld's media player from the wearable or starting an intent on the wearable from the handheld. Messages are also great for one-way requests or for a request/response communication model.
Data Events Channel / Message
![Page 27: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/27.jpg)
For Demonstration of the Data Sync we create a full screen UI wearable app An Android wear application is nearly identical to a normal smartphone app. In our example we will use the Data API to exchange Data between the Wear device and the companion app running on the smart phone. For our example we could also use the Message API.
Extend the MainActivity if you want to listen to data events on the UI Thread.
// Main Activity public class MainActivity extends Activity
implements ConnectionCallbacks, OnConnectionFailedListener, DataApi.DataListener, MessageApi.MessageListener, NodeApi.NodeListener {
... Your App Code goes here @Override public void onDataChanged(DataEventBuffer dataEvents) { ....
If you want to listen to Data change Events
![Page 28: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/28.jpg)
Speech Recognition Voice actions (System- or App provided “OK Google, …) and the system's built-in Speech Recognizer activity can be used to obtain speech input from users.
// Create an intent that can start the Speech Recognizer activity private void displaySpeechRecognizer() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); // Start the activity, the intent will be populated with the speech text startActivityForResult(intent, SPEECH_REQUEST_CODE); } // invoked when the Speech Recognizer returns, extract the speech text from the intent. @Override protected void onActivityResult(int requestCode, int resultCode,Intent data) { if (resultCode == RESULT_OK) { List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); chatterText = results.get(0); <create & send the data event> }
![Page 29: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/29.jpg)
Sending Data A DataItem defines the data interface that the system uses to synchronize data between handhelds and wearables. A DataItem generally consists of the following items:
§ Payload - A byte array, which you can set with whatever data you wish, allowing you to do your own object serialization and deserialization. The size of the payload is limited to 100KB.
§ Path - A unique string that must start with a forward slash (for instance, "/salesforce/wearable/chatter")
// Create a data map and put data in it private void createChatterData(String post) { //Create the data request object PutDataMapRequest putDataMapReq = PutDataMapRequest.create (“/chatter "); putDataMapReq.getDataMap().putString(CHATTER_KEY, post); PutDataRequest putDataReq = putDataMapReq.asPutDataRequest(); // Adds a DataItem to the Android Wear network. à synchronized across all devices PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq); } ...
![Page 30: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/30.jpg)
A DataLayerService will listen on all data events The data layer synchronizes and sends data across the handheld and wearable, you normally want to listen for important events, such as when data items are created, are received, etc. Options:
§ Create a service that extends WearableListenerService.
§ Create an activity that implements DataApi.DataListener.
public class DataLayerListenerService extends WearableListenerService { /.../ @Override public void onDataChanged(DataEventBuffer dataEvents) {
if (!mGoogleApiClient.isConnected()... //check for connectivity!!! // Loop through the events for (DataEvent event : dataEvents) { Uri uri = event.getDataItem().getUri(); String path = uri.getPath(); if (COUNT_PATH.equals(path)) {
// get the payload byte[] payload = uri.toString().getBytes(); // *Chatter something J postChatterMessage(payload); ...
Leveraging the MobileSDK
(Authentication, Rest Calls etc…)
* See https://github.com/forcedotcom/JavaChatterRESTApi by Jasper Roel
![Page 31: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/31.jpg)
Speech Recognition is a great feature, but...
Hello Chatter Dreamforce is Awesome
Willkommen auf der Dreamforce
Who needs the Apple Watch?
Who will win the Super
Bowl?
![Page 32: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/32.jpg)
Key Takeaways
§ Keep your Wear UI as simple as possible!!!
§ Always test on real devices
§ The Salesforce Mobile SDK and Connected Apps handle most of the connection complexity for your application
§ Wear Devices are mainly informative devices or to automatically collect data
§ The Notification is a great and simple way to expand your existing Android app to Wear Watches without the need to code a custom Wear app
![Page 33: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/33.jpg)
Share Your Feedback, and Win a GoPro!
3 Earn a GoPro prize entry for each completed survey Tap the bell to take a survey 2 Enroll in a session 1
![Page 34: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/34.jpg)
Thank you
![Page 35: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/35.jpg)
Thank you Backup Slides
![Page 36: See Androids Fighting: Connect Salesforce with Your Android Wear Watch](https://reader033.vdocuments.mx/reader033/viewer/2022051710/5a65cef87f8b9a3d248b46a3/html5/thumbnails/36.jpg)
UI Building Blocks - Android Wear is different! Users are used to tapping icons to launch apps. A typical Wear app adds a card to the stream at a contextually relevant moment. It might have a button that opens a full screen view, but it just as well might not.
Application Type Device Devlopment
Contextual card in the stream
Bridged notifications, such as new message notifications, are pushed to the wearable from the connected handheld using standard Android notifications. They require very little or no Wear-specific code.
✗
Contextual notifications, such as an exercise card that appears when you begin running, are generated locally on the wearable and appear at contextually relevant moments. You can do more with this kind of card than with a notification bridged from the handheld.
✔
Full screen UI app: 2D Picker is a design pattern that allows the user to select from a set of items, such as to select an artist then an album. We recommend using this pre-built component from the SDK whenever relevant.
✔
Custom layouts are also possible where apps need to extend beyond the basic card/stream metaphor, such as to present a graph or map. ✔ Keep your app always-on if you have information that refreshes or stays relevant, without draining the battery. ✔
Watch Face Android Wear supports custom watch faces with designs that can show contextually relevant information to users. ✔