当前位置: 首页>>代码示例>>Java>>正文


Java MessageEvent.getSourceNodeId方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.MessageEvent.getSourceNodeId方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getSourceNodeId方法的具体用法?Java MessageEvent.getSourceNodeId怎么用?Java MessageEvent.getSourceNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.MessageEvent的用法示例。


在下文中一共展示了MessageEvent.getSourceNodeId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:27,代码来源:WatchFaceWearableListenerService.java

示例2: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@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();
    }
}
 
开发者ID:mauriciotogneri,项目名称:shoppinglist,代码行数:21,代码来源:WearableService.java

示例3: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:mauriciotogneri,项目名称:tpgwear,代码行数:25,代码来源:WearableService.java

示例4: WearExchangeMessageEvent

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
public WearExchangeMessageEvent(MessageEvent messageEvent) {
    if(messageEvent == null) {
        Log.e(getClass().getSimpleName(), "MessageEvent is null in constructor");
        return;
    }

    requestId = messageEvent.getRequestId();
    path = messageEvent.getPath();
    data = messageEvent.getData();
    sourceNodeId = messageEvent.getSourceNodeId();
}
 
开发者ID:RileyGB,项目名称:WearExchange,代码行数:12,代码来源:WearExchangeMessageEvent.java

示例5: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    mRecentNodeId = messageEvent.getSourceNodeId();

    if (WearMessages.MESSAGE_COMMAND.equalsIgnoreCase(messageEvent.getPath())) {
        mRequestEngine.sendCommand(RequestEngine.Command.valueOf(new String(messageEvent.getData())));
    } else if (WearMessages.MESSAGE_STATUS.equalsIgnoreCase(messageEvent.getPath())) {
        mRequestEngine.requestStatus(this);
    } else if (WearMessages.MESSAGE_BOT_LIST.equalsIgnoreCase(messageEvent.getPath())) {
        sendBotList();
    } else if (WearMessages.MESSAGE_BOT_SELECT.equalsIgnoreCase(messageEvent.getPath())) {
        selectBot(new String(messageEvent.getData()));
    }
}
 
开发者ID:rampage128,项目名称:hombot-control,代码行数:15,代码来源:WearListenerService.java

示例6: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals(Constant.PATH_FAVOURITES_FETCH_MOBILE)) {
        nodeId = messageEvent.getSourceNodeId();

        List<CharSequence> listFavouriteStops = getListFavouriteStops();

        replyFavourites(PATH_FAVOURITES_FETCH_WEAR, listFavouriteStops);
    }

    if (messageEvent.getPath().equals(Constant.PATH_FAVOURITES_OPEN_APP_MOBILE)) {
        nodeId = messageEvent.getSourceNodeId();

        startActivity(
                new Intent(
                        this,
                        MainActivity.class
                ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        );
    }

    if (messageEvent.getPath().equals(Constant.PATH_STOPFORECAST_FETCH_MOBILE)) {
        nodeId = messageEvent.getSourceNodeId();

        String stopName = Serializer.deserialize(messageEvent.getData()).toString();

        if (stopName != null)
            fetchStopForecast(stopName);
    }
}
 
开发者ID:thecosmicfrog,项目名称:LuasataGlance,代码行数:31,代码来源:WearMessageListenerService.java

示例7: fetchMessageEvent

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
public void fetchMessageEvent(MessageEvent messageEvent) {
	if (messageEvent.getPath().equalsIgnoreCase(CONNECTED_PATH)) {
		if (!wearConnected) {
			mConnectedNodes.add(messageEvent.getSourceNodeId());
			wearConnected = true;
		}
	} else if (watchPaths.contains(messageEvent.getPath())) {
		String[] values = new String[]{messageEvent.getSourceNodeId(), messageEvent.getPath(), messageEvent.getData().toString()};
		Intent updatedIntent = new Intent(messageEvent.getPath());
		updatedIntent.putExtra("message", values);
		LocalBroadcastManager.getInstance(mContext).sendBroadcast(updatedIntent);
	}
}
 
开发者ID:ngageoint,项目名称:mage-chronostouch-android,代码行数:14,代码来源:DataManager.java

示例8: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
    // get id of wear device
    String id = messageEvent.getSourceNodeId();
    String action = messageEvent.getPath();
    if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_RUN)) {
        startVibration(messageEvent);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_DEL)) {
        stopVibration();
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE)) {
        deleteCanvas();
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER)) {
        startSensorService(id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER)) {
        stopSensorService(id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_UNREGISTER, id);
    } else {
        if (BuildConfig.DEBUG) {
            Log.e("Wear", "unknown event");
        }
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:62,代码来源:DataLayerListenerService.java

示例9: onMessageReceived

import com.google.android.gms.wearable.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    nodeId = messageEvent.getSourceNodeId();
    MainActivity.sendMessage(messageEvent.getPath());
    showToast(messageEvent.getPath());
}
 
开发者ID:HackFmiNpe,项目名称:TheForceMediaCenter,代码行数:7,代码来源:ListenerService.java


注:本文中的com.google.android.gms.wearable.MessageEvent.getSourceNodeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。