Java 类com.google.android.gms.wearable.MessageEvent 实例源码

项目:Android-Wear-Projects    文件:HeartListener.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/heartRate")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("heart", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:StepListner.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/stepcount")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:ListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals("/message_path")) {
        final String message = new String(messageEvent.getData());
        Log.v("myTag", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("myTag", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:WearListner.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/from-wear")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:ListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals("/message_path")) {
        final String message = new String(messageEvent.getData());
        Log.v("myTag", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("myTag", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:WearListner.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/from-wear")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:HeartListener.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/heartRate")) {
        final String message = new String(messageEvent.getData());
        Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath());
        Log.v("packtchat", "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("heart", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:Android-Wear-Projects    文件:StepListner.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/stepcount")) {
        final String message = new String(messageEvent.getData());
        Log.v(TAG, "Message path received from wear is: " + messageEvent.getPath());
        Log.v(TAG, "Message received on watch is: " + message);

        // Broadcast message to wearable activity for display
        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:ibm-wearables-android-sdk    文件:MessageReceiverService.java   
/**
 * Handle messages from the phone
 * @param messageEvent new message from the phone
 */
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals("/start")) {
        dataManager.turnSensorOn(Integer.valueOf(new String(messageEvent.getData())));
    }

    else if (messageEvent.getPath().equals("/stop")){
        dataManager.turnSensorOff(Integer.valueOf(new String(messageEvent.getData())));
    }

    else if (messageEvent.getPath().equals("/stopAll")){
        dataManager.turnAllSensorsOff();
    }

    else if (messageEvent.getPath().equals("/ping")){
        NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await();
        for(Node node : nodes.getNodes()) {
            Wearable.MessageApi.sendMessage(apiClient, node.getId(), "/connected", null).await();
        }
    }
}
项目:WeaRemote    文件:AppListenerService123.java   
@Override
public void onMessageReceived(MessageEvent messageEvent)
{
    super.onMessageReceived(messageEvent);

    if (messageEvent.getPath().equals(START_ACTIVITY_PATH))
    {
        Intent intent = new Intent(this, SpaceRemoteActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

        Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
        long[] vibrationPattern = {0, 75, 50, 75};
        vibrator.vibrate(vibrationPattern, -1);
    }
}
项目:android-samples    文件:WearService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    //This method will call while any message is posted by the watch to the phone.
    //This is message api, so if the phone is not connected message will be lost.
    //No guarantee of the message delivery

    //check path of the message
    if (messageEvent.getPath().equalsIgnoreCase(STEP_COUNT_MESSAGES_PATH)) {

        //Extract the values
        String stepCount = new String(messageEvent.getData());
        Log.d("Step count: ", stepCount + " ");

        //send broadcast to update the UI in MainActivity based on the tracking status
        Intent intent = new Intent(TRACKING_COUNT_ACTION);
        intent.putExtra("step-count", stepCount);
        LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
    } else {
        super.onMessageReceived(messageEvent);
    }
}
项目:adrenaline_watch_face    文件:WatchFaceWearableListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);
    Log.d("WEAR", "Message received: " + messageEvent);
    nodeId = messageEvent.getSourceNodeId();

    //Toast.makeText(this, "Command received", Toast.LENGTH_LONG).show();
    if (messageEvent.getPath().contains(LAST_KNOW_GPS_POSITION)) {

        new Thread(){
            @Override
            public void run() {
                super.run();
                try {
                    LocationManager locationManager = (LocationManager) WatchFaceWearableListenerService.this.getSystemService(Context.LOCATION_SERVICE);
                    String locationProvider = LocationManager.NETWORK_PROVIDER;
                    // Or use LocationManager.GPS_PROVIDER
                    Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
                    if(lastKnownLocation != null) {
                        reply(LAST_KNOW_GPS_POSITION, lastKnownLocation.getLatitude() + "_" + lastKnownLocation.getLongitude());
                    }
                }catch (Exception e){e.printStackTrace();}
            }
        }.start();
    }
}
项目:Mycroft-Android    文件:MycroftWearListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    String message = new String(messageEvent.getData());

    if (messageEvent.getPath().equals(Constants.MYCROFT_QUERY_MESSAGE_PATH)) {
        Log.d(TAG, "MycroftWearRequest Message: " + message);

        Intent startIntent = new Intent(this, MainActivity.class);
        startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startIntent.putExtra("MYCROFT_WEAR_REQUEST", message);
        startActivity(startIntent);

        handoffWearRequest(message);
    }
}
项目:stayawhile-android    文件:WearMessageHandler.java   
@Override
public void onMessageReceived(MessageEvent messageEvent){
    if( messageEvent.getPath().equalsIgnoreCase( "/saw_repl" ) ) {
        //String msg = messageEvent.getData();
        Log.i("DEV", "Got queue sent confirmation!");
    }
    else if (messageEvent.getPath().equalsIgnoreCase(SEND_UPDATE_REQUEST)){
        try {
            sendQueueToWear(mQueue);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    else if (messageEvent.getPath().equalsIgnoreCase(SEND_KICK_USER)){
        kickUser(messageEvent.getData());
    }
    else if (messageEvent.getPath().equalsIgnoreCase(SEND_ATTEND_USER)){
        attendUser(messageEvent.getData());
    } else {
        super.onMessageReceived( messageEvent );
    }
}
项目:MirageWatch    文件:HandheldMsgReceiverService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);

    if (messageEvent.getPath().equals("/BatteryLevel")) {
        String s = new String(messageEvent.getData());

        Log.d(this.getClass().getSimpleName(), "受信したバッテリーレベル = " + s);

        MyWearApplication app = (MyWearApplication) getApplication();
        try {
            app.setBatteryLevel(Integer.parseInt(s));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
}
项目:MirageWatch    文件:WearableMsgReceiverService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);

    String path = messageEvent.getPath();

    switch (path) {
        case "/RequestBatteryLevel":
            Log.d(sTag, "バッテリーレベル要求を受信");

            mApiClient = new GoogleApiClient.Builder(
                    getApplicationContext(), mConnectionCallback, mConnFailedCallback)
                    .addApi(Wearable.API)
                    .build();
            mApiClient.connect();
            break;
    }
}
项目:PainlessMusicPlayer    文件:WearableListenerServiceImpl.java   
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);
    switch (messageEvent.getPath()) {
        case DataPaths.Messages.SEARCH_RESULT:
            WearSearchData.Results searchResults = null;
            final byte[] data = messageEvent.getData();
            if (data != null && data.length != 0) {
                try {
                    searchResults = WearSearchData.Results.parseFrom(data);
                } catch (InvalidProtocolBufferNanoException e) {
                    Log.w(TAG, e);
                }
            }
            if (searchResults == null) {
                searchResults = new WearSearchData.Results();
            }
            EventBus.getDefault().post(new EventSearchResults(searchResults));
            break;
    }
}
项目:WearExchange    文件:WearExchangeService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    // Guard Clauses
    if (knownMessagePathList == null || knownMessagePathList.isEmpty()) {
        Log.e(getClass().getSimpleName(), "KnownMessagePathList is empty/null");
        return;
    }
    else if (messageEvent == null || messageEvent.getPath() == null) {
        Log.e(getClass().getSimpleName(), "MessageEvent or its path is null");
        return;
    }

    for (String knownMessagePath : knownMessagePathList) {
        if (messageEvent.getPath().equals(knownMessagePath)) {
            // Try to send a local broadcast, if it fails, send an intent
            if (canSendEventBusMessage()) {
                EventBus.getDefault().post(new WearExchangeMessageEvent(messageEvent));
            } else {
                sendIntentMessage(messageEvent);
            }

            break;
        }
    }
}
项目:powerhour    文件:GameListenerService.java   
@Override
public void onMessageReceived(MessageEvent event) {
    String path = event.getPath();
    Log.d(TAG, "onMessageReceived: Path " + path);

    switch (path) {
        case Consts.Paths.START_ACTIVITY:
            startActivity(createActivityIntent(false));
            break;
        case Consts.Paths.GAME_SHOT:
            GameState.getInstance().setIsShotTime(true);
            mVibrator.vibrate(VIBRATE_PATTERN, -1);

            startActivity(createActivityIntent(true));
            break;
        case Consts.Paths.GAME_INFORMATION:
            GameState.getInstance().setIsShotTime(false);
            break;
    }
    super.onMessageReceived(event);
}
项目:DeviceConnect-Android    文件:WearManager.java   
/**
 * Android Wearのリスナーを設定する.
 */
private void setMessageListener() {
    Wearable.MessageApi.addListener(mGoogleApiClient, new MessageApi.MessageListener() {
        @Override
        public void onMessageReceived(final MessageEvent messageEvent) {
            final String data = new String(messageEvent.getData());
            final String path = messageEvent.getPath();
            final String nodeId = messageEvent.getSourceNodeId();
            mLogger.info("onMessageReceived: path = " + path + ":node:" + nodeId);
            OnMessageEventListener listener = mOnMessageEventListeners.get(path);
            if (listener != null) {
                listener.onEvent(nodeId, data);
            }
        }
    });
}
项目:DeviceConnect-Android    文件:DataLayerListenerService.java   
/**
 * バイブレーションを開始する.
 * @param messageEvent メッセージ
 */
private void startVibration(final MessageEvent messageEvent) {
    // get vibration pattern
    String mPattern = new String(messageEvent.getData());

    // Make array of pattern
    String[] mPatternArray = mPattern.split(",", 0);
    long[] mPatternLong = new long[mPatternArray.length + 1];
    mPatternLong[0] = 0;
    for (int i = 1; i < mPatternLong.length; i++) {
        mPatternLong[i] = Integer.parseInt(mPatternArray[i - 1]);
    }

    Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vibrator.vibrate(mPatternLong, -1);
}
项目:shoppinglist    文件:WearableService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent)
{
    String nodeId = messageEvent.getSourceNodeId();
    String path = messageEvent.getPath();
    byte[] payload = messageEvent.getData();

    if (TextUtils.equals(path, Paths.GET_CART))
    {
        getCart(nodeId);
    }
    else if (TextUtils.equals(path, Paths.MARK_CART_ELEMENT))
    {
        markCartElement(payload);
    }
    else if (TextUtils.equals(path, Paths.CLEAR_SELECTED))
    {
        clearSelected();
    }
}
项目:WeaRSS    文件:PhoneFromWearListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (OPEN_URL_PATH.equals(messageEvent.getPath())) {
        SendHeadline receivedHeadline = new Gson().fromJson(new String(messageEvent.getData()), SendHeadline.class);

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        String readListPref = prefs.getString(getString(R.string.key_prefs_read_item_tap), "0");
        boolean appShareFromWatch = prefs.getBoolean(getString(R.string.key_prefs_article_select_from_watch), false);
        if (appShareFromWatch && readListPref.equals(SettingsActivity.TAP_SPECIFIC_APP_VALUE)) {
            new DeviceAppService().shareToSpecificSelectedApp(this, receivedHeadline);
        } else {
            receivedHeadline.setInReadList(true);

            if (!HeadlinesService.isArticleInList(receivedHeadline.getArticleUrl())) {
                receivedHeadline.save();
            }

            Intent intent = new Intent(this, FeedsMainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            intent.putExtra(OPEN_READ_LIST_EXTRA, true);
            startActivity(intent);

            sendBroadcast(new Intent(getString(R.string.receive_headline_intent)));
        }
    }
}
项目:fantasywear    文件:ListenerService.java   
@Override
public void onMessageReceived(MessageEvent message) {
    if (Paths.SYNC.equals(message.getPath())) {
        FWLog.i("Received a sync request; manually syncing all accounts");
        SyncAdapter.requestManualSync(this);
    } else if (Paths.ACK.equals(message.getPath())) {
        Uri uri;
        try {
            uri = Uri.parse(new String(message.getData(), "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException("UTF-8 must be a supported encoding", e);
        }
        FWLog.d("Received an ACK for URI %s", uri);
        LocalBroadcasts.sendAckBroadcast(this, uri);
    } else {
        FWLog.e("Unknown message path: %s", message.getPath());
    }
}
项目:wearbooksource    文件:WMessageHandheldActivity.java   
@Override
public void onMessageReceived( final MessageEvent messageEvent ) {
    Log.d ( TAG, "onMessageReceived() messageEvent=" + messageEvent) ;
    Log.d(TAG, "onMessageReceived() messageEvent=" + messageEvent.getPath() + " " +  messageEvent.getSourceNodeId() + " " +  new String  (  messageEvent.getData() ) ) ;
    //dataTextView.setText( new String (messageEvent.getData()) );


    runOnUiThread(new Runnable() {
        @Override
        public void run() {
           // dataTextView.setText(messageEvent.getPath() + messageEvent.getSourceNodeId() + String.valueOf(messageEvent.getData()));
            //dataTextView.setText( String.valueOf(messageEvent.getData() ));
            dataTextView.setText( new String (messageEvent.getData() ));

        }
    });


}
项目:AndroidCourses    文件:WearableMessageListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals("/MainActivity")) {
        final String message = new String(messageEvent.getData());
        Log.i(TAG, "Message path received on watch is: " + messageEvent.getPath());
        Log.i(TAG, "Message received on watch is: " + message);

        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("message", message);
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
    }
    else {
        super.onMessageReceived(messageEvent);
    }
}
项目:amaroKontrol    文件:DataLayerListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    // new request to start the app
    // all this should probably happen only if notification not up/app is really starting
    if (messageEvent.getPath().equals(Constants.COMM_START)) {
        NotificationUtils.issueNotification("amaroKontrol", "", null, null);
        Commander.getInstance().sendCommand(Constants.COMM_FORCE_REFRESH, null);
    }

    // request to clera notification - app on phone has ended
    else if (messageEvent.getPath().equals(Constants.COMM_CLEAR_NOTIFICATION)) {
        Log.d("clearing notification from wear");
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancelAll();

    }
}
项目:PowerSwitch_Android    文件:ListenerService.java   
/**
 * This method is called when a message from a wearable device is received
 *
 * @param messageEvent
 */
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    LogHandler.configureLogger();

    if (messageEvent.getPath().equals(WearableConstants.RECEIVER_ACTION_TRIGGER_PATH)) {

        String messageData = new String(messageEvent.getData());
        Log.d("Wear_ListenerService", "Message received: " + messageData);

        // trigger api intent
        parseMessage(messageData);
    } else if (messageEvent.getPath().equals(WearableConstants.REQUEST_DATA_UPDATE_PATH)) {
        UtilityService.forceWearDataUpdate(this);
    } else if (messageEvent.getPath().equals(WearableConstants.REQUEST_SETTINGS_UPDATE_PATH)) {
        UtilityService.forceWearSettingsUpdate(this);
    }
}
项目:watchpresenter    文件:WearMessageListener.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (Log.isLoggable(Constants.LOG_TAG, Log.DEBUG)) {
        Log.d(Constants.LOG_TAG, "onDataChanged: " + messageEvent);
    }

    final String messagePath = messageEvent.getPath();
    if(messagePath != null){
        if(messagePath.equals(Constants.NEXT_SLIDE_GESTURE_DETECTED_PATH)) {
            Log.d(Constants.LOG_TAG, "Next slide message received from Wear device...");
            Intent intent = new Intent(SendMessageReceiver.INTENT);
            intent.putExtra(Constants.EXTRA_MESSAGE, Constants.NEXT_SLIDE_MESSAGE);
            sendBroadcast(intent);
        }
        else{
            Log.i(Constants.LOG_TAG, "Received message with unknown path: " + messagePath);
        }
    }
    else{
        Log.e(Constants.LOG_TAG, "Message with null path: " + messageEvent);
    }
}
项目:WearCam    文件:MainActivity.java   
@Override
public void onMessageReceived(MessageEvent _messageEvent) {
    final String temp = _messageEvent.getPath();
    if (temp.equals(MyConstants.PATH_STOP)) {
        finish();
    }else if (temp.equals(MyConstants.PATH_START_RECORDING)) {
        Log.i(TAG,"wear path start recording received");
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                startRedDotAnimation();
            }
        });

        //TODO: implement counter here
    }else if(temp.equals(MyConstants.PATH_STOP_RECORDING)){
        Log.i(TAG,"wear path stop recording received");
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                stopRedDotAnimation();
            }
        });
        //TODO: implement counter here
    }
}
项目:Wear-Emmet    文件:Emmet.java   
public Emmet onCreate(Context context, ConnectionListener connectionListener) {
    mConnectionListener = connectionListener;

    mApiClient = new GoogleApiClient.Builder(context.getApplicationContext())
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();
    Wearable.MessageApi.addListener(mApiClient, new MessageApi.MessageListener() {
        @Override
        public void onMessageReceived(MessageEvent messageEvent) {
            onMessageReceived(messageEvent);
        }
    });
    Wearable.DataApi.addListener(mApiClient, new DataApi.DataListener() {
        @Override
        public void onDataChanged(DataEventBuffer dataEventBuffer) {
            onDataChanged(dataEventBuffer);
        }
    });
    mApiClient.connect();

    return this;
}
项目:PavlovWatchface    文件:ListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) {

        String message = new String(messageEvent.getData());
        if (message.equals("NewLocation")) {
            Log.d(TAG, "Got message for New Location");
            Intent promptIntent = new Intent(getApplicationContext(), PromptActivity.class);
            promptIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(promptIntent);
        }
        else if (message.startsWith("MEAN")){
            String[] messageHalves = message.split(",");
            String[] mean = messageHalves[0].split(":");
            String[] stdev = messageHalves[1].split(":");
            Log.d(TAG, "Got message for mean and stdev");
            SharedPreferences prefs = getSharedPreferences("FuzzyTime", MODE_PRIVATE);
            SharedPreferences.Editor editor = prefs.edit();
            editor.putInt("key_mean", Integer.valueOf(mean[1]));
            editor.putInt("key_stdev", Integer.valueOf(stdev[1]));
            editor.apply();
        }
    }
}
项目:WearSocket    文件:WearSocket.java   
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
    if (messageEvent.getPath().equals(receiverPath)) {
        ((Activity)context).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                String data = null;
                try {
                    data = new String(messageEvent.getData(),"UTF-8");
                    messageReceived.messageReceived(messageEvent.getPath(), data);
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
项目:MirageWatch    文件:HandheldMsgReceiverService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);

    if (messageEvent.getPath().equals("/BatteryLevel")) {
        String s = new String(messageEvent.getData());

        Log.d(this.getClass().getSimpleName(), "受信したバッテリーレベル = " + s);

        MyWearApplication app = (MyWearApplication) getApplication();
        try {
            app.setBatteryLevel(Integer.parseInt(s));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
    }
}
项目:MirageWatch    文件:WearableMsgReceiverService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);

    String path = messageEvent.getPath();

    switch (path) {
        case "/RequestBatteryLevel":
            Log.d(sTag, "バッテリーレベル要求を受信");

            mApiClient = new GoogleApiClient.Builder(
                    getApplicationContext(), mConnectionCallback, mConnFailedCallback)
                    .addApi(Wearable.API)
                    .build();
            mApiClient.connect();
            break;
    }
}
项目:GlanceTweet    文件:TweetListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    Log.d(Constants.TAG, "onMessageReceived " + messageEvent.getPath() + " " + messageEvent.getRequestId() );
    if (messageEvent.getPath().equals(Constants.WEAR_GA_PATH)) {
        Parcel parcel = Parcel.obtain();
        parcel.unmarshall(messageEvent.getData(), 0, messageEvent.getData().length);
        parcel.setDataPosition(0);

        AnalyticsEvent event = (AnalyticsEvent) AnalyticsEvent.CREATOR.createFromParcel(parcel);
        tracker.send(new HitBuilders.EventBuilder()
                .setCategory(event.getCategory())
                .setAction(event.getAction())
                .setLabel(event.getLabel())
                .setValue(event.getValue())
                .build());
        Log.d(Constants.TAG, "sending analytics ");
    }
}
项目:powerhour    文件:GameActivity.java   
@Override
public void onMessageReceived(MessageEvent event) {
    Log.d(TAG, "onMessageReceived: " + event);
    switch (event.getPath()) {
        case Consts.Paths.GAME_SHOT:
            Log.d(TAG, "onMessageReceived: SHOT TIME");
            GameState.getInstance().setIsShotTime(true);
            mGameScreen.updateScreen(isAmbient());
            break;
        case Consts.Paths.GAME_STOP:
            Log.d(TAG, "onMessageReceived: Game has stopped");
            GameState.getInstance().stop();
            updateDisplay();
            Message.sendReady(this);
            break;
        case Consts.Paths.GAME_FINISH:
            Log.i(TAG, "onMessageReceived: Game has finished");
            Wearable.DataApi.removeListener(mGoogleApiClient, this);
            Wearable.MessageApi.removeListener(mGoogleApiClient, this);
            finish();
            break;
    }
}
项目:airhero_watch_face    文件:WatchFaceWearableListenerService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);
    Log.d("WEAR", "Message received: " + messageEvent);
    nodeId = messageEvent.getSourceNodeId();

    //Toast.makeText(this, "Command received", Toast.LENGTH_LONG).show();
    if (messageEvent.getPath().contains(LAST_KNOW_GPS_POSITION)) {

        new Thread(){
            @Override
            public void run() {
                super.run();
                try {
                    LocationManager locationManager = (LocationManager) WatchFaceWearableListenerService.this.getSystemService(Context.LOCATION_SERVICE);
                    String locationProvider = LocationManager.NETWORK_PROVIDER;
                    // Or use LocationManager.GPS_PROVIDER
                    Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
                    if(lastKnownLocation != null) {
                        reply(LAST_KNOW_GPS_POSITION, lastKnownLocation.getLatitude() + "_" + lastKnownLocation.getLongitude());
                    }
                }catch (Exception e){e.printStackTrace();}
            }
        }.start();
    }
}
项目:WearControl    文件:SoundProfileListener.java   
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);
    SoundProfile profile = SoundProfile.valueOf(messageEvent.getPath());

    switch (profile) {
        case SOUND_ON:
            audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
            break;

        case SOUND_OFF:
            audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
            break;

        case VIBRATE:
            audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
            break;

    }

    Log.d(Const.TAG, "on profile changed: " + profile.name());
}
项目:tpgwear    文件:WearableService.java   
@Override
public void onMessageReceived(MessageEvent messageEvent)
{
    String nodeId = messageEvent.getSourceNodeId();
    String path = messageEvent.getPath();
    String payload = EncodingHelper.getBytesAsString(messageEvent.getData());

    if (TextUtils.equals(path, Paths.GET_FAVORITE_STOPS))
    {
        getFavoriteStops(nodeId);
    }
    else if (TextUtils.equals(path, Paths.GET_DEPARTURES))
    {
        getDepartures(nodeId, payload);
    }
    else if (TextUtils.equals(path, Paths.GET_TRIP))
    {
        getTrip(nodeId, payload);
    }
    else if (TextUtils.equals(path, Paths.INCREASE_STOP_HIT_COUNT))
    {
        increaseStopHitCount(payload);
    }
}