introduction to android wear - files.meetup.com wear ( gdg baltimore ) p… · introduction to...
TRANSCRIPT
Introduction to Android Wear#AndroidWear
FPO: verify rights
REAL LIFE
GET PHONE
LOST IN PHONE
you talk to the wearable
actions
actions
the wearable talks to you
actions
actions
context
actions
context
Notifications
Notifications
Notifications
NO WORK REQUIRED
Notifications
NO WORK REQUIRED
Notifications
Stacks Pages Replies
Custom UI Send Data
Control Sensors Voice Actions
Apps
What’s next?Getting Started with Android Wear developer.android.com/wear
Android WearBuilding Your First App
Launch the app once to make it able to receive notifications
What you will needJDK
Android Studio Device with the Android Wear Preview beta app installed
wearable-preview-support.zip Android Wear emulator
Check your development environment
22.6 or aboveAndroid Wear ARM
EABI v7a System Image
Create an emulator
4.4.2 or above
Android Wear
Android Wear
Snapshot
Launch the emulator
Device is not connected
Connect to the emulator
Connect the device with the Android Wear Preview beta app installed to your development PC using USB.
In the directory where your Android SDK is installed, execute:adb -d forward tcp:5601 tcp:5601
Run the emulator
Device is connected
Create a new projectInput as
appropriate
Select Android 4.4
Select Android 4.0
Only check “Create Activity"
Create a new project
Select “Blank Activity"
Finish
Create a new project
Install wearable-preview-support
Extract wearable-preview-support.zip. Create a libs/ directory in your project root and copy the wearable-
preview-support.jar file there.
Edit build.gradleOpen build.gradle under modules.
The wearable-preview-support.jar and Android support-v4 dependency rules will be added.
dependencies { compile 'com.android.support:support-v4:+' compile files(‘../libs/wearable-preview-support.jar') }
Sync Project with Gradle Files
Create a layoutAdd a button to activity_main.xml
Create a notification iconRight click on “res" and select “Image Asset"
Select Notification Icons
As desired
Create a notification icon
Finish
Edit MainActivityAdd imports to Addsrc\main\java\<package>\MainActivity
import android.preview.support.wearable.notifications.*; import android.preview.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationCompat;
Automatic importing (Command-Enter) is usually fine, but for notifications, be sure to specify so that the SupportLibrary and normal APIs do not get
mixed up
Implement View.OnclickListener
Use any method for implementing OnClickListener. public class MainActivity extends Activity implements View.OnClickListener {
Edit MainActivity
Edit MainActivityAcquire Button and register View.OnClickListener
private Button mButton;
mButton = (Button) findViewById(R.id.button); mButton.setOnClickListener(this);
Implement an event that occurs when the user taps
Edit MainActivity
Execute the app
Tap the button...
Execute the app
A notification is generated
Execute the app
This is displayed simultaneously on Android
Wear
Execute the app
Quit the smartphone app
Execute the app
Swipe upward.
Execute the app
Swipe to the left and “Open” is displayed.
Tap “Open” and a PendingIntent is issued, and MainActivity opens
Execute the app
You can also add actions other than opening an Activity
Execute the app
Google Now.
http://www.google.com/landing/now/#cards
http://www.google.com/landing/now/integrations.html
https://developers.google.com/schemas/now/cards
https://developers.google.com/schemas/reference/event-reservation
GDG Baltimore
Thank You.