本文整理汇总了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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}
示例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()));
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
}
示例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());
}