本文整理匯總了Java中com.google.android.gms.wearable.MessageEvent.getPath方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageEvent.getPath方法的具體用法?Java MessageEvent.getPath怎麽用?Java MessageEvent.getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.wearable.MessageEvent
的用法示例。
在下文中一共展示了MessageEvent.getPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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;
}
}
示例2: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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;
}
}
示例3: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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;
}
}
}
示例4: 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();
}
}
示例5: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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);
}
}
示例6: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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;
}
}
示例7: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@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);
}
示例8: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
final String message = new String(messageEvent.getData());
switch (messageEvent.getPath()) {
case Constants.UART.DEVICE_CONNECTED: {
// Disconnect action
final Intent disconnectIntent = new Intent(ActionReceiver.ACTION_DISCONNECT);
disconnectIntent.putExtra(ActionReceiver.EXTRA_DATA, Constants.UART.PROFILE);
final PendingIntent disconnectAction = PendingIntent.getBroadcast(this, UART_DISCONNECT, disconnectIntent, PendingIntent.FLAG_CANCEL_CURRENT);
// Open action
final Intent intent = new Intent(this, UARTConfigurationsActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(this, UART_SHOW_CONFIGURATIONS, intent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentIntent(pendingIntent)
.setOngoing(true)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(getString(R.string.notif_uart_device_connected))
.setContentText(message)
.addAction(new NotificationCompat.Action(R.drawable.ic_full_bluetooth, getString(R.string.action_disconnect), disconnectAction))
.setLocalOnly(true);
NotificationManagerCompat.from(this).notify(UART_NOTIFICATION_ID, builder.build());
break;
}
case Constants.UART.DEVICE_LINKLOSS:
case Constants.UART.DEVICE_DISCONNECTED: {
NotificationManagerCompat.from(this).cancel(UART_NOTIFICATION_ID);
}
default:
super.onMessageReceived(messageEvent);
break;
}
}
示例9: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
// If the activity is binded to service it means that it has connected directly to the device. We ignore messages from the handheld.
if (mProfile != null)
return;
switch (messageEvent.getPath()) {
case Constants.UART.DEVICE_LINKLOSS:
case Constants.UART.DEVICE_DISCONNECTED: {
finish();
break;
}
}
}
示例10: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
// If the activity is binded to service it means that it has connected directly to the device. We ignore messages from the handheld.
if (mBinder != null)
return;
switch (messageEvent.getPath()) {
case Constants.UART.DEVICE_LINKLOSS:
case Constants.UART.DEVICE_DISCONNECTED: {
finish();
break;
}
}
}
示例11: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
switch (messageEvent.getPath()) {
case Constants.ACTION_DISCONNECT: {
// A disconnect message was sent. The information which profile should be disconnected is in the data.
final String profile = new String(messageEvent.getData());
switch (profile) {
// Currently only UART profile has Wear support
case Constants.UART.PROFILE: {
final Intent disconnectIntent = new Intent(UARTService.ACTION_DISCONNECT);
disconnectIntent.putExtra(UARTService.EXTRA_SOURCE, UARTService.SOURCE_WEARABLE);
sendBroadcast(disconnectIntent);
break;
}
}
break;
}
case Constants.UART.COMMAND: {
final String command = new String(messageEvent.getData());
final Intent intent = new Intent(UARTService.ACTION_SEND);
intent.putExtra(UARTService.EXTRA_SOURCE, UARTService.SOURCE_WEARABLE);
intent.putExtra(Intent.EXTRA_TEXT, command);
sendBroadcast(intent);
}
default:
super.onMessageReceived(messageEvent);
break;
}
}
示例12: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageEvent messageEvent)
{
String path = messageEvent.getPath();
byte[] data = messageEvent.getData();
String sData = new String(data);
Log.d("OnMessageReceived", "UnityWearListener P: " + path + " D: " + sData);
if(messageEvent.getPath().equals(PublicConstants.STOP_ACTIVITY))
{
AppSharedPreferences.setAppOpen(getApplicationContext(), false);
super.onMessageReceived(messageEvent);
}else
{
if (!AppSharedPreferences.getAppOpen(getApplicationContext()) && messageEvent.getPath().equals(PublicConstants.START_ACTIVITY))//|| !messageEvent.getPath().contains(PublicConstants.STOP_ACTIVITY))
{
/*if (messageEvent.getPath().contains(PublicConstants.START_ACTIVITY))
{*/
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
//}
} else
{
Log.d("Listener", "App Opened yet jeje");
super.onMessageReceived(messageEvent);
}
}
}
示例13: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageEvent messageEvent) {
Log.d(TAG, "onMessageReceived: " + messageEvent);
String path = messageEvent.getPath();
Log.d(TAG, "message path: " + path);
// Check to see if the message is a request for the updated weather conditions
if (path.equals(REQ_WEATHER_PATH)) {
// start the service sending the updated weather condition to the wearable
Context context = this.getApplicationContext();
context.startService(new Intent(context, WearableIntentService.class));
}
}
示例14: onMessageReceived
import com.google.android.gms.wearable.MessageEvent; //導入方法依賴的package包/類
@Override
public void onMessageReceived(MessageEvent messageEvent) {
String msg = messageEvent.getPath();
Log.d("service","receive and start");
sendBroadcast(new Intent("Setting"));
}
示例15: 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();
}