Posts

Wear gist#4: How to use a simple a GridViewPager with a FragmentGridPagerAdapter

Image
It is very simple to use the FragmentGridPagerAdapter in your Android Wear App. You can build a new CardFragment with the default layout including title, text and icon using the method: CardFragment.create(page.mTitle, page.mText, page.mIconId) Also you can provide a background overriding the getBackground(int row, int col) method in your adapter. Very useful the class ImageReference which provides a reference to an image Here a small gist

Wear gist #3:how to start an Activity on the mobile handheld from the Android Wear device

You can start an Activity on the mobile handheld from your Wear device. In order to achieve it you have to: In your wear activity: connect the GoogleApiClient get the node [1] connected send the message with the Wearable.MessageApi.sendMessage [2] In your mobile app: register a WearableListenerService start the intent when the message is received Here a little (and improvable) gist: https://gist.github.com/gabrielemariotti/117b05aad4db251f7534 [1]: http://developer.android.com/reference/com/google/android/gms/wearable/NodeApi.html#getConnectedNodes(com.google.android.gms.common.api.GoogleApiClient) [2]: http://developer.android.com/reference/com/google/android/gms/wearable/MessageApi.html#sendMessage(com.google.android.gms.common.api.GoogleApiClient, java.lang.String, java.lang.String, byte[])

Wear gist#2: Battery details

Image
Here a little gist to get details from your battery in your wear device. https://gist.github.com/gabrielemariotti/b49cf077d184e8b26378

Wear gist#1: How to get the heart rate on the Samsung Gear Live.

Image
Here a little gist to get the heart rate on the Samsung Gear Live. https://gist.github.com/gabrielemariotti/d23bfe583e900a4f9276

Android-L gist#1 : Floating Action Button

Image
Here you can find a little gist to build a simple Floating Action Button with shadow, ripple and outline . Of course it requires Android-L preview. Link https://gist.github.com/gabrielemariotti/d1baf785c2444d29819c This code is built watching the #io14 videos, and mainly checking code at https://github.com/romainguy/google-io-2014 .

GPlayServices #1: Save to Google Drive

Image
A little snippet to save a file (or some contents) in Google Drive with the Drive API included in the Google Play Services . To use the Google Drive API we have to follow these steps:(this blog doesn't cover these topics) : Set Up Google Play Services SDK Register your app in Google Developers Console to activate the API Now we can build our code. First of all, we have to create an instance of GoogleApiClient using the GoogleApiClient.Builder and implementing the callback interfaces to manage the connection and the authorizations as described in GPlay Service #0 . Our scope is to save a file (an image) choosing a folder in Google Drive. To choose a folder inside our Google Drive we can use the Drive.DriveApi.newOpenFileActivityBuilder() . This method creates a builder for an Open File activity that allows user selection of a Drive file. Upon completion, the result Intent will contain the DriveId for the selected file. We can use the OnConnected interface to know...

GPlayServices #0: Configure the GoogleApiClient with Google Play Services.

Image
A little snippet to connect your app with the Google Play Services API. To use the Google Play Services API you have to follow these steps:(this blog doesn't cover these topics) : Set Up Google Play Services SDK Register your app in Google Developers Console to activate the API Now you can build your code. First of all, create an instance of GoogleApiClient using the GoogleApiClient.Builder. /** * Called when activity gets visible. A connection to Drive services need to * be initiated as soon as the activity is visible. Registers * {@code ConnectionCallbacks} and {@code OnConnectionFailedListener} on the * activities itself. */ @Override protected void onResume() { super.onResume(); if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Drive.API) .addScope(Drive.SCOPE_FILE) .addScope(Drive.SCOPE_APPFOLDER) ...