### Install PebbleKit Android SDK via Gradle Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Add the PebbleKit SDK to your Android project by including the necessary repositories and dependencies in your app's build.gradle file. This ensures your project can access the SDK's functionalities. ```groovy // app/build.gradle repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/groups/public/" } } dependencies { compile 'com.getpebble:pebblekit:4.0.1@aar' } ``` -------------------------------- ### Integrate with Pebble Sports App using SportsState Helper (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt This snippet demonstrates how to use the SportsState helper class to send real-time sports data to the Pebble watch's built-in Sports app. It covers initializing the helper, starting and stopping workouts, and updating various metrics like time, distance, pace, and heart rate. Dependencies include the PebbleKit SDK and Android's Handler and Looper for managing updates. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.Constants; import com.getpebble.android.kit.util.SportsState; public class SportsActivity extends AppCompatActivity { private SportsState sportsState; private Handler updateHandler; private Runnable updateRunnable; private int elapsedSeconds = 0; private float totalDistance = 0.0f; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize SportsState helper sportsState = new SportsState(); updateHandler = new Handler(Looper.getMainLooper()); } public void startWorkout() { // Launch the Sports app on the watch PebbleKit.startAppOnPebble(getApplicationContext(), Constants.SPORTS_UUID); // Start periodic updates updateRunnable = new Runnable() { @Override public void run() { updateSportsData(); updateHandler.postDelayed(this, 1000); // Update every second } }; updateHandler.post(updateRunnable); } private void updateSportsData() { elapsedSeconds++; totalDistance += 0.005f; // Simulated distance increment // Set time (0-35999 seconds, displays as h:mm:ss) sportsState.setTimeInSec(elapsedSeconds); // Set distance (0-99.9, in km or miles based on unit setting) sportsState.setDistance(totalDistance); // Set pace (seconds per km/mile, 0-3599, displays as mm:ss) int paceSecondsPerKm = (int) (elapsedSeconds / Math.max(0.1f, totalDistance)); sportsState.setPaceInSec(Math.min(paceSecondsPerKm, 3599)); // OR set speed instead of pace (km/h or mph, 0-99.9) // float speed = totalDistance / (elapsedSeconds / 3600.0f); // sportsState.setSpeed(speed); // Set heart rate (optional) sportsState.setHeartBPM((byte) 145); // Set custom label and value (optional) sportsState.setCustomLabel("Calories"); sportsState.setCustomValue(String.valueOf(elapsedSeconds * 5)); // Synchronize to watch - only sends changed values sportsState.synchronize(getApplicationContext()); } public void stopWorkout() { if (updateHandler != null && updateRunnable != null) { updateHandler.removeCallbacks(updateRunnable); } PebbleKit.closeAppOnPebble(getApplicationContext(), Constants.SPORTS_UUID); } } ``` -------------------------------- ### Create and Populate PebbleDictionary (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Demonstrates how to create a new PebbleDictionary and add various data types including strings, signed/unsigned integers of different bit sizes, and byte arrays. This is fundamental for preparing data to be sent to a Pebble device. ```java import com.getpebble.android.kit.util.PebbleDictionary; import org.json.JSONException; public class DictionaryOperations { public PebbleDictionary createDictionary() { PebbleDictionary dict = new PebbleDictionary(); // Add various data types dict.addString(0, "Hello"); // String dict.addInt8(1, (byte) -100); // Signed 8-bit dict.addUint8(2, (byte) 200); // Unsigned 8-bit dict.addInt16(3, (short) -30000); // Signed 16-bit dict.addUint16(4, (short) 60000); // Unsigned 16-bit dict.addInt32(5, -2000000000); // Signed 32-bit dict.addUint32(6, 4000000000); // Unsigned 32-bit dict.addBytes(7, new byte[] {0x01, 0x02, 0x03}); // Byte array return dict; } public void readFromDictionary(PebbleDictionary dict) { // Check if key exists if (dict.contains(0)) { String strValue = dict.getString(0); Log.d("Dict", "String value: " + strValue); } // Read signed integers Long signedValue = dict.getInteger(1); if (signedValue != null) { Log.d("Dict", "Signed int: " + signedValue); } // Read unsigned integers (returned as Long to handle full range) Long unsignedValue = dict.getUnsignedIntegerAsLong(2); if (unsignedValue != null) { Log.d("Dict", "Unsigned int: " + unsignedValue); } // Read byte array byte[] bytes = dict.getBytes(7); if (bytes != null) { Log.d("Dict", "Bytes length: " + bytes.length); } // Get dictionary size int size = dict.size(); Log.d("Dict", "Dictionary contains " + size + " entries"); } public void iterateDictionary(PebbleDictionary dict) { // Iterate over all tuples in the dictionary for (com.getpebble.android.kit.util.PebbleTuple tuple : dict) { Log.d("Dict", String.format("Key: %d, Type: %s, Value: %s", tuple.key, tuple.type.name(), tuple.value.toString())); } } public void modifyDictionary(PebbleDictionary dict) { // Remove a key-value pair dict.remove(3); // Replace existing value (same key, new value) dict.addString(0, "Updated Hello"); } public String serializeToJson(PebbleDictionary dict) { // Convert to JSON string for storage or transmission return dict.toJsonString(); } public PebbleDictionary deserializeFromJson(String jsonString) { try { return PebbleDictionary.fromJson(jsonString); } catch (JSONException e) { Log.e("Dict", "Failed to parse JSON: " + e.getMessage()); return null; } } } ``` -------------------------------- ### Add PebbleKit Android Dependency with Maven Source: https://github.com/pebble/pebble-android-sdk/blob/master/README.md Includes the PebbleKit Android library in a Maven project by adding a dependency configuration to the pom.xml file. This allows Maven to manage and download the library from the Sonatype repository. ```xml com.getpebble pebblekit 4.0.1 aar ``` -------------------------------- ### Add PebbleKit Android Dependency with Gradle Source: https://github.com/pebble/pebble-android-sdk/blob/master/README.md Integrates the PebbleKit Android library into an Android Studio or Gradle project by adding a dependency to the app/build.gradle file. It also requires specifying the Sonatype OSS Repository for dependency resolution. ```gradle dependencies { compile 'com.getpebble:pebblekit:4.0.1@aar' } repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/groups/public/" } } ``` -------------------------------- ### Android PebbleKit Integration Source: https://context7.com/pebble/pebble-android-sdk/llms.txt This Java code demonstrates a complete integration of PebbleKit within an Android Activity. It handles watch connection/disconnection events, registers receivers for data and acknowledgments from the watch, and includes methods for sending data to the watch. Dependencies include the PebbleKit SDK and Android support libraries. ```java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.PebbleKit.*; import com.getpebble.android.kit.util.PebbleDictionary; import java.util.UUID; public class PebbleIntegrationActivity extends AppCompatActivity { private static final UUID APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); private static final int KEY_COMMAND = 0; private static final int KEY_DATA = 1; private BroadcastReceiver connectedReceiver; private BroadcastReceiver disconnectedReceiver; private PebbleDataReceiver dataReceiver; private PebbleAckReceiver ackReceiver; private PebbleNackReceiver nackReceiver; private int currentTransactionId = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Check initial connection state if (PebbleKit.isWatchConnected(getApplicationContext())) { onWatchConnected(); } } @Override protected void onResume() { super.onResume(); registerReceivers(); } @Override protected void onPause() { super.onPause(); unregisterReceivers(); } private void registerReceivers() { // Connection receivers connectedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onWatchConnected(); } }; PebbleKit.registerPebbleConnectedReceiver(getApplicationContext(), connectedReceiver); disconnectedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { onWatchDisconnected(); } }; PebbleKit.registerPebbleDisconnectedReceiver(getApplicationContext(), disconnectedReceiver); // Data receiver dataReceiver = new PebbleDataReceiver(APP_UUID) { @Override public void receiveData(Context context, int transactionId, PebbleDictionary data) { handleReceivedData(data); PebbleKit.sendAckToPebble(context, transactionId); } }; PebbleKit.registerReceivedDataHandler(getApplicationContext(), dataReceiver); // ACK/NACK receivers ackReceiver = new PebbleAckReceiver(APP_UUID) { @Override public void receiveAck(Context context, int transactionId) { Log.d("Pebble", "Message " + transactionId + " delivered"); } }; PebbleKit.registerReceivedAckHandler(getApplicationContext(), ackReceiver); nackReceiver = new PebbleNackReceiver(APP_UUID) { @Override public void receiveNack(Context context, int transactionId) { Log.w("Pebble", "Message " + transactionId + " failed, retrying..."); // Implement retry logic here } }; PebbleKit.registerReceivedNackHandler(getApplicationContext(), nackReceiver); } private void unregisterReceivers() { if (connectedReceiver != null) unregisterReceiver(connectedReceiver); if (disconnectedReceiver != null) unregisterReceiver(disconnectedReceiver); if (dataReceiver != null) unregisterReceiver(dataReceiver); if (ackReceiver != null) unregisterReceiver(ackReceiver); if (nackReceiver != null) unregisterReceiver(nackReceiver); } private void onWatchConnected() { Log.d("Pebble", "Watch connected"); PebbleKit.startAppOnPebble(getApplicationContext(), APP_UUID); } private void onWatchDisconnected() { Log.d("Pebble", "Watch disconnected"); } private void handleReceivedData(PebbleDictionary data) { Long command = data.getUnsignedIntegerAsLong(KEY_COMMAND); if (command != null) { switch (command.intValue()) { case 1: // Example: Button press handleButtonPress(); break; case 2: // Example: Request data sendDataToWatch(); break; } } } private void handleButtonPress() { Log.d("Pebble", "Button pressed on watch"); } public void sendDataToWatch() { PebbleDictionary data = new PebbleDictionary(); data.addUint8(KEY_COMMAND, (byte) 1); data.addString(KEY_DATA, "Hello from Android!"); currentTransactionId = (currentTransactionId + 1) % 256; PebbleKit.sendDataToPebbleWithTransactionId( getApplicationContext(), ``` -------------------------------- ### Receive Logged Data from Pebble Watch (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt This Java code snippet demonstrates how to set up a receiver for logged data from a Pebble watch. It handles different data types and session completion events. Ensure the PebbleKit library is included in your project. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.PebbleKit.PebbleDataLogReceiver; import java.util.UUID; public class DataLoggingActivity extends AppCompatActivity { private static final UUID MY_APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); private PebbleDataLogReceiver dataLogReceiver; @Override protected void onResume() { super.onResume(); // Create data log receiver dataLogReceiver = new PebbleDataLogReceiver(MY_APP_UUID) { // Handle unsigned integer data @Override public void receiveData(Context context, UUID logUuid, Long timestamp, Long tag, Long data) { Log.d("PebbleApp", String.format( "Received uint data - Log: %s, Time: %d, Tag: %d, Value: %d", logUuid.toString(), timestamp, tag, data)); } // Handle signed integer data @Override public void receiveData(Context context, UUID logUuid, Long timestamp, Long tag, int data) { Log.d("PebbleApp", String.format( "Received int data - Log: %s, Time: %d, Tag: %d, Value: %d", logUuid.toString(), timestamp, tag, data)); } // Handle byte array data @Override public void receiveData(Context context, UUID logUuid, Long timestamp, Long tag, byte[] data) { Log.d("PebbleApp", String.format( "Received bytes - Log: %s, Time: %d, Tag: %d, Length: %d bytes", logUuid.toString(), timestamp, tag, data.length)); // Process the byte array data processReceivedBytes(data); } // Called when a logging session finishes @Override public void onFinishSession(Context context, UUID logUuid, Long timestamp, Long tag) { Log.d("PebbleApp", String.format( "Session finished - Log: %s, Time: %d, Tag: %d", logUuid.toString(), timestamp, tag)); // All data for this session has been received onSessionComplete(logUuid); } }; // Register the data log receiver PebbleKit.registerDataLogReceiver(getApplicationContext(), dataLogReceiver); // Request any pending data logs for our app PebbleKit.requestDataLogsForApp(getApplicationContext(), MY_APP_UUID); } @Override protected void onPause() { super.onPause(); if (dataLogReceiver != null) { unregisterReceiver(dataLogReceiver); dataLogReceiver = null; } } private void processReceivedBytes(byte[] data) { // Process logged sensor data, activity data, etc. } private void onSessionComplete(UUID logUuid) { // Handle session completion - save to database, upload to server, etc. } } ``` -------------------------------- ### Launch and Close Pebble Watch Apps (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Launches or closes a specific watch application on a connected Pebble smartwatch using its unique UUID. This method supports launching custom apps as well as built-in applications like Sports and Golf. Requires application context and the watch app's UUID. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.Constants; import java.util.UUID; public class WatchAppController { // Define your watchapp's UUID (must match the UUID in your Pebble app) private static final UUID MY_APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); public void launchMyWatchApp(Context context) { // Launch custom watch app PebbleKit.startAppOnPebble(context.getApplicationContext(), MY_APP_UUID); Log.d("PebbleApp", "Launched watch app"); } public void closeMyWatchApp(Context context) { // Close the watch app PebbleKit.closeAppOnPebble(context.getApplicationContext(), MY_APP_UUID); Log.d("PebbleApp", "Closed watch app"); } public void launchBuiltInSportsApp(Context context) { // Launch the built-in Sports app using the predefined UUID PebbleKit.startAppOnPebble(context.getApplicationContext(), Constants.SPORTS_UUID); } public void launchBuiltInGolfApp(Context context) { // Launch the built-in Golf app using the predefined UUID PebbleKit.startAppOnPebble(context.getApplicationContext(), Constants.GOLF_UUID); } } ``` -------------------------------- ### Customize Pebble Sports and Golf Apps with Branding (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt This Java code snippet shows how to apply custom branding, including a name and icon, to the built-in Sports and Golf applications on a Pebble watch. It utilizes the PebbleKit's `customizeWatchApp` method, requiring a Context, the app type (Sports or Golf), a custom name string (max 32 characters), and a Bitmap for the icon (max 25x25 pixels, black and white). Error handling for invalid arguments is included. ```java import android.graphics.Bitmap; import android.graphics.BitmapFactory; import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.Constants.PebbleAppType; public class AppCustomizer { public void customizeSportsApp(Context context) { // Load a custom icon (must be 25x25 pixels max, black and white) Bitmap icon = BitmapFactory.decodeResource( context.getResources(), R.drawable.custom_sports_icon ); // Verify icon dimensions if (icon.getWidth() > 25 || icon.getHeight() > 25) { // Scale down if needed icon = Bitmap.createScaledBitmap(icon, 25, 25, true); } // Apply custom branding (name must be <= 32 characters) try { PebbleKit.customizeWatchApp( context.getApplicationContext(), PebbleAppType.SPORTS, "My Running App", // Custom name icon // Custom icon ); Log.d("PebbleApp", "Sports app customized successfully"); } catch (IllegalArgumentException e) { Log.e("PebbleApp", "Failed to customize: " + e.getMessage()); } } public void customizeGolfApp(Context context) { Bitmap golfIcon = BitmapFactory.decodeResource( context.getResources(), R.drawable.custom_golf_icon ); PebbleKit.customizeWatchApp( context.getApplicationContext(), PebbleAppType.GOLF, "Pro Golf Tracker", golfIcon ); } } ``` -------------------------------- ### Handle ACK/NACK Responses with Pebble Android SDK Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Register receivers to track whether sent messages were successfully delivered to the watch. This involves setting up ACK and NACK handlers to log delivery status and provide user feedback. Requires PebbleKit library. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.PebbleKit.PebbleAckReceiver; import com.getpebble.android.kit.PebbleKit.PebbleNackReceiver; import java.util.UUID; public class MessageTrackingActivity extends AppCompatActivity { private static final UUID MY_APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); private PebbleAckReceiver ackReceiver; private PebbleNackReceiver nackReceiver; @Override protected void onResume() { super.onResume(); // Register ACK handler - called when watch successfully receives message ackReceiver = new PebbleAckReceiver(MY_APP_UUID) { @Override public void receiveAck(Context context, int transactionId) { Log.d("PebbleApp", "Message ACKed: transaction " + transactionId); // Message was successfully delivered to the watch runOnUiThread(() -> { Toast.makeText(context, "Message delivered!", Toast.LENGTH_SHORT).show(); }); } }; PebbleKit.registerReceivedAckHandler(getApplicationContext(), ackReceiver); // Register NACK handler - called when watch fails to receive message nackReceiver = new PebbleNackReceiver(MY_APP_UUID) { @Override public void receiveNack(Context context, int transactionId) { Log.e("PebbleApp", "Message NACKed: transaction " + transactionId); // Message delivery failed - consider retrying runOnUiThread(() -> { Toast.makeText(context, "Message failed, retrying...", Toast.LENGTH_SHORT).show(); }); } }; PebbleKit.registerReceivedNackHandler(getApplicationContext(), nackReceiver); } @Override protected void onPause() { super.onPause(); if (ackReceiver != null) { unregisterReceiver(ackReceiver); ackReceiver = null; } if (nackReceiver != null) { unregisterReceiver(nackReceiver); nackReceiver = null; } } } ``` -------------------------------- ### Receive Data from Pebble Watch (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Registers a receiver to handle data sent from a Pebble watch to an Android app. Processes received data, including strings and integers, and sends acknowledgments to prevent watch timeouts. Requires PebbleKit SDK and proper receiver lifecycle management. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.PebbleKit.PebbleDataReceiver; import com.getpebble.android.kit.util.PebbleDictionary; import java.util.UUID; public class DataReceiverActivity extends AppCompatActivity { private static final UUID MY_APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); // Define expected message keys from the watch private static final int KEY_BUTTON_EVENT = 0; private static final int KEY_ACCELEROMETER_X = 1; private static final int KEY_ACCELEROMETER_Y = 2; private static final int KEY_ACCELEROMETER_Z = 3; private PebbleDataReceiver dataReceiver; @Override protected void onResume() { super.onResume(); // Create and register the data receiver dataReceiver = new PebbleDataReceiver(MY_APP_UUID) { @Override public void receiveData(Context context, int transactionId, PebbleDictionary data) { // Process received data Log.d("PebbleApp", "Received data from watch, transaction: " + transactionId); // Read string values String buttonEvent = data.getString(KEY_BUTTON_EVENT); if (buttonEvent != null) { Log.d("PebbleApp", "Button event: " + buttonEvent); } // Read integer values Long accelX = data.getInteger(KEY_ACCELEROMETER_X); Long accelY = data.getInteger(KEY_ACCELEROMETER_Y); Long accelZ = data.getInteger(KEY_ACCELEROMETER_Z); if (accelX != null && accelY != null && accelZ != null) { Log.d("PebbleApp", String.format("Accel: X=%d, Y=%d, Z=%d", accelX, accelY, accelZ)); } // Read unsigned integers as Long Long unsignedValue = data.getUnsignedIntegerAsLong(10); // Read byte arrays byte[] rawData = data.getBytes(20); // IMPORTANT: Always ACK received messages to prevent watch timeouts PebbleKit.sendAckToPebble(context, transactionId); } }; // Register the receiver PebbleKit.registerReceivedDataHandler(getApplicationContext(), dataReceiver); } @Override protected void onPause() { super.onPause(); // IMPORTANT: Always unregister to prevent memory leaks if (dataReceiver != null) { unregisterReceiver(dataReceiver); dataReceiver = null; } } } ``` -------------------------------- ### Monitor Pebble Connection Events with Android SDK Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Register receivers to be notified when a Pebble watch connects or disconnects. This allows your application to react to the watch's connection status, such as updating the UI or launching the watch app. Requires PebbleKit library. ```java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.getpebble.android.kit.PebbleKit; public class ConnectionMonitorActivity extends AppCompatActivity { private BroadcastReceiver connectedReceiver; private BroadcastReceiver disconnectedReceiver; @Override protected void onResume() { super.onResume(); // Register connection receiver connectedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d("PebbleApp", "Pebble connected!"); runOnUiThread(() -> { updateConnectionStatus(true); // Optionally launch your watch app // PebbleKit.startAppOnPebble(context, MY_APP_UUID); }); } }; PebbleKit.registerPebbleConnectedReceiver(getApplicationContext(), connectedReceiver); // Register disconnection receiver disconnectedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d("PebbleApp", "Pebble disconnected!"); runOnUiThread(() -> { updateConnectionStatus(false); }); } }; PebbleKit.registerPebbleDisconnectedReceiver(getApplicationContext(), disconnectedReceiver); } @Override protected void onPause() { super.onPause(); if (connectedReceiver != null) { unregisterReceiver(connectedReceiver); connectedReceiver = null; } if (disconnectedReceiver != null) { unregisterReceiver(disconnectedReceiver); disconnectedReceiver = null; } } private void updateConnectionStatus(boolean connected) { // Update UI based on connection status } } ``` -------------------------------- ### Send Data to Pebble Watch (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Sends key-value pairs from an Android app to a Pebble watch using PebbleDictionary. Supports various data types like integers, strings, and byte arrays. Requires the PebbleKit SDK and a defined app UUID. ```java import com.getpebble.android.kit.PebbleKit; import com.getpebble.android.kit.util.PebbleDictionary; import java.util.UUID; public class DataSender { private static final UUID MY_APP_UUID = UUID.fromString("12345678-1234-1234-1234-123456789abc"); // Define message keys (must match your watchapp's keys) private static final int KEY_TEMPERATURE = 0; private static final int KEY_CITY_NAME = 1; private static final int KEY_CONDITION = 2; private static final int KEY_WIND_SPEED = 3; public void sendWeatherData(Context context) { // Create a dictionary with key-value pairs PebbleDictionary data = new PebbleDictionary(); // Add different data types data.addInt32(KEY_TEMPERATURE, 72); // Signed 32-bit integer data.addString(KEY_CITY_NAME, "San Francisco"); // String value data.addUint8(KEY_CONDITION, (byte) 1); // Unsigned 8-bit integer data.addInt16(KEY_WIND_SPEED, (short) 15); // Signed 16-bit integer // Send data to the watch app PebbleKit.sendDataToPebble(context.getApplicationContext(), MY_APP_UUID, data); Log.d("PebbleApp", "Sent weather data to watch"); } public void sendDataWithTransaction(Context context) { PebbleDictionary data = new PebbleDictionary(); data.addString(0, "Hello Pebble!"); // Send with a transaction ID for tracking ACK/NACK responses int transactionId = 42; PebbleKit.sendDataToPebbleWithTransactionId( context.getApplicationContext(), MY_APP_UUID, data, transactionId ); } public void sendBinaryData(Context context) { PebbleDictionary data = new PebbleDictionary(); // Send raw bytes byte[] imageData = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04 }; data.addBytes(5, imageData); PebbleKit.sendDataToPebble(context.getApplicationContext(), MY_APP_UUID, data); } } ``` -------------------------------- ### Check Pebble Watch Connection Status (Java) Source: https://context7.com/pebble/pebble-android-sdk/llms.txt Synchronously checks if a Pebble watch is connected via Bluetooth using PebbleKit. It also verifies if AppMessage and data logging are supported, and retrieves firmware version information. Requires application context. ```java import com.getpebble.android.kit.PebbleKit; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check if a Pebble watch is connected boolean isConnected = PebbleKit.isWatchConnected(getApplicationContext()); if (isConnected) { Log.d("PebbleApp", "Pebble watch is connected!"); // Check if AppMessage is supported boolean appMsgSupported = PebbleKit.areAppMessagesSupported(getApplicationContext()); Log.d("PebbleApp", "AppMessage supported: " + appMsgSupported); // Check if data logging is supported boolean dataLoggingSupported = PebbleKit.isDataLoggingSupported(getApplicationContext()); Log.d("PebbleApp", "Data logging supported: " + dataLoggingSupported); // Get firmware version info PebbleKit.FirmwareVersionInfo fwInfo = PebbleKit.getWatchFWVersion(getApplicationContext()); if (fwInfo != null) { Log.d("PebbleApp", String.format("Firmware: %d.%d.%d %s", fwInfo.getMajor(), fwInfo.getMinor(), fwInfo.getPoint(), fwInfo.getTag())); } } else { Log.d("PebbleApp", "No Pebble watch connected"); } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.