本文整理汇总了Java中com.getpebble.android.kit.PebbleKit.sendAckToPebble方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleKit.sendAckToPebble方法的具体用法?Java PebbleKit.sendAckToPebble怎么用?Java PebbleKit.sendAckToPebble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.PebbleKit
的用法示例。
在下文中一共展示了PebbleKit.sendAckToPebble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void receiveData(int transactionId, PebbleDictionary data) {
Log.d(TAG, "receiveData: transactionId is " + String.valueOf(transactionId));
lastTransactionId = transactionId;
Log.d(TAG, "Received Query. data: " + data.size() + ".");
if (data.size() > 0) {
pebble_sync_value = data.getUnsignedIntegerAsLong(SYNC_KEY);
pebble_platform = data.getUnsignedIntegerAsLong(PLATFORM_KEY);
pebble_app_version = data.getString(VERSION_KEY);
Log.d(TAG, "receiveData: pebble_sync_value=" + pebble_sync_value + ", pebble_platform=" + pebble_platform + ", pebble_app_version=" + pebble_app_version);
} else {
Log.d(TAG, "receiveData: pebble_app_version not known");
}
PebbleKit.sendAckToPebble(context, transactionId);
transactionFailed = false;
transactionOk = false;
messageInTransit = false;
sendStep = 5;
sendData();
}
示例2: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void receiveData(int transactionId, PebbleDictionary data) {
Log.d(TAG, "receiveData: transactionId is " + String.valueOf(transactionId));
if (PebbleWatchSync.lastTransactionId == 0 || transactionId != PebbleWatchSync.lastTransactionId) {
PebbleWatchSync.lastTransactionId = transactionId;
Log.d(TAG, "Received Query. data: " + data.size() + ". sending ACK and data");
PebbleKit.sendAckToPebble(this.context, transactionId);
sendData();
} else {
Log.d(TAG, "receiveData: lastTransactionId is " + String.valueOf(PebbleWatchSync.lastTransactionId) + ", sending NACK");
PebbleKit.sendNackToPebble(this.context, transactionId);
}
}
示例3: receiveAppData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public static void receiveAppData(int transactionId, PebbleDictionary data) {
Log.d(TAG, "receiveAppData: transactionId is " + String.valueOf(transactionId));
AlertPlayer.getPlayer().Snooze(xdrip.getAppContext(), -1);
PebbleKit.sendAckToPebble(xdrip.getAppContext(), transactionId);
JoH.static_toast_long("Alarm snoozed by pebble");
}
示例4: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void receiveData(int transactionId, PebbleDictionary data) {
Log.d(TAG, "receiveData: transactionId is " + String.valueOf(transactionId));
this.pebbleWatchSync.lastTransactionId = transactionId;
Log.d(TAG, "Received Query. data: " + data.size() + ".");
PebbleKit.sendAckToPebble(this.context, transactionId);
evaluateDataFromPebble(data);
transactionFailed = false;
transactionOk = false;
messageInTransit = false;
sendStep = 5;
sendData();
}
示例5: onReceive
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
try {
// Intent from Pebble Android app
String json = intent.getStringExtra(Constants.MSG_DATA);
PebbleDictionary dict = PebbleDictionary.fromJson(json);
// Is this a job for Captain Dash API?
if(dict.getInteger(Keys.AppKeyUsesDashAPI) == null) {
return;
}
UUID uuid = (UUID)intent.getSerializableExtra(Constants.APP_UUID);
Log.d(TAG, "Packet received from " + uuid.toString());
// ACK
int transactionId = intent.getIntExtra(TRANSACTION_ID, -1);
PebbleKit.sendAckToPebble(context, transactionId);
// Call Service
Intent i = new Intent(context, Service.class);
i.putExtra("json", json);
i.putExtra("uuid", uuid.toString());
context.startService(i);
} catch(Exception e) {
Log.e(TAG, "Error getting PebbleDictionary from JSON");
e.printStackTrace();
}
}
示例6: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void receiveData(Context context, int transactionId, PebbleDictionary data) {
FollowState followMe = dpApi.getFollowState();
if(followMe == null)
return ;
PebbleKit.sendAckToPebble(applicationContext, transactionId);
int request = (data.getInteger(KEY_PEBBLE_REQUEST).intValue());
switch (request) {
case KEY_REQUEST_MODE_FOLLOW:
if(followMe.isEnabled()){
dpApi.disableFollowMe();
}
else {
dpApi.enableFollowMe(followMe.getMode());
}
break;
case KEY_REQUEST_CYCLE_FOLLOW_TYPE:
List<FollowType> followTypes = Arrays.asList(FollowType.values());
int currentTypeIndex = followTypes.indexOf(followMe.getMode());
int nextTypeIndex = currentTypeIndex++ % followTypes.size();
dpApi.enableFollowMe(followTypes.get(nextTypeIndex));
break;
case KEY_REQUEST_PAUSE:
dpApi.pauseAtCurrentLocation();
break;
case KEY_REQUEST_MODE_RTL:
dpApi.changeVehicleMode(VehicleMode.COPTER_RTL);
break;
}
}
示例7: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void receiveData(final Context context, final int transactionId, final String jsonPacket, Class<? extends PebbleTalkerService> talkerClass)
{
PebbleKit.sendAckToPebble(context, transactionId);
Intent intent = new Intent(context, talkerClass);
intent.setAction(PebbleTalkerService.INTENT_PEBBLE_PACKET);
intent.putExtra("packet", jsonPacket);
context.startService(intent);
}
示例8: onResume
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
// Reset game
mChoice = Keys.CHOICE_WAITING;
mWinCounter = 0;
mGameCounter = 0;
updateUI();
// Register to get updates from Pebble
if(mDataReceiver == null) {
mDataReceiver = new PebbleKit.PebbleDataReceiver(APP_UUID) {
@Override
public void receiveData(Context context, int transactionId, PebbleDictionary dict) {
// Always ACK
PebbleKit.sendAckToPebble(context, transactionId);
// Was a choice received from player 2?
if(dict.getInteger(Keys.KEY_CHOICE) != null) {
mP2Choice = dict.getInteger(Keys.KEY_CHOICE).intValue();
if(mChoice != Keys.CHOICE_WAITING) {
// A match can be played!
doMatch();
}
}
}
};
PebbleKit.registerReceivedDataHandler(getApplicationContext(), mDataReceiver);
}
}
示例9: onResume
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
if(mDataReceiver == null) {
mDataReceiver = new PebbleKit.PebbleDataReceiver(APP_UUID) {
@Override
public void receiveData(Context context, int transactionId, PebbleDictionary dict) {
// Always ACK
PebbleKit.sendAckToPebble(context, transactionId);
Log.i("receiveData", "Got message from Pebble!");
// Up received?
if(dict.getInteger(KEY_BUTTON_UP) != null) {
previousPage();
}
// Down received?
if(dict.getInteger(KEY_BUTTON_DOWN) != null) {
nextPage();
}
}
};
PebbleKit.registerReceivedDataHandler(getApplicationContext(), mDataReceiver);
}
}
示例10: handleReceivedData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Acks and handles a received message (starts service if not currently running). Should be called by the PebbleDataBroadcastReceiver for all (data) messages from the watch
*
* @param context
* @param msgData
* the msgData (json String) from the original intent
* @param transactionId
*/
public static void handleReceivedData(Context context, String msgData, int transactionId) {
// Ack the message
PebbleKit.sendAckToPebble(context, transactionId);
// Relay message to the service
if (instance == null)
Log.d("PebbleCommunication", "Reviving service because of incoming Pebble message");
Intent intent = new Intent(context, AgendaWatchfaceService.class);
intent.setAction(INTENT_ACTION_HANDLE_WATCHAPP_MESSAGE);
intent.putExtra(com.getpebble.android.kit.Constants.MSG_DATA, msgData);
context.startService(intent);
}
示例11: onReceive
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void onReceive( final Context context, final Intent intent )
{
if( Constants.INTENT_APP_RECEIVE.equals( intent.getAction() ) )
{
Log.i( TAG, "Received messaged from Pebble App." );
final UUID receivedUuid = (UUID) intent.getSerializableExtra( Constants.APP_UUID );
// Pebble-enabled apps are expected to be good citizens and only inspect broadcasts containing their UUID
if( !PebbleApp.UUID.equals( receivedUuid ) )
{
Log.i( TAG, "not my UUID" );
return;
}
final int transactionId = intent.getIntExtra( Constants.TRANSACTION_ID, -1 );
final String jsonData = intent.getStringExtra( Constants.MSG_DATA );
if( jsonData == null || jsonData.isEmpty() )
{
Log.w( TAG, "jsonData null" );
PebbleKit.sendNackToPebble( context, transactionId );
return;
}
Log.w( TAG, "Sending ACK to Pebble. " + transactionId );
PebbleKit.sendAckToPebble( context, transactionId );
Log.w( TAG, "Starting RingerService..." );
Intent serviceIntent = new Intent( context, RingerService.class );
serviceIntent.putExtra( Constants.TRANSACTION_ID, transactionId );
serviceIntent.putExtra( Constants.MSG_DATA, jsonData );
startWakefulService( context, serviceIntent );
}
}
示例12: onResume
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
// Construct output String
StringBuilder builder = new StringBuilder();
builder.append("Pebble Info\n\n");
// Is the watch connected?
boolean isConnected = PebbleKit.isWatchConnected(this);
builder.append("Watch connected: " + (isConnected ? "true" : "false")).append("\n");
// What is the firmware version?
PebbleKit.FirmwareVersionInfo info = PebbleKit.getWatchFWVersion(this);
builder.append("Firmware version: ");
builder.append(info.getMajor()).append(".");
builder.append(info.getMinor()).append("\n");
// Is AppMessage supported?
boolean appMessageSupported = PebbleKit.areAppMessagesSupported(this);
builder.append("AppMessage supported: " + (appMessageSupported ? "true" : "false"));
TextView textView = (TextView)findViewById(R.id.text_view);
textView.setText(builder.toString());
// Push a notification
final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");
final Map data = new HashMap();
data.put("title", "Test Message");
data.put("body", "Whoever said nothing was impossible never tried to slam a revolving door.");
final JSONObject jsonData = new JSONObject(data);
final String notificationData = new JSONArray().put(jsonData).toString();
i.putExtra("messageType", "PEBBLE_ALERT");
i.putExtra("sender", "PebbleKit Android");
i.putExtra("notificationData", notificationData);
sendBroadcast(i);
// Get information back from the watchapp
if(mReceiver == null) {
mReceiver = new PebbleKit.PebbleDataReceiver(Constants.SPORTS_UUID) {
@Override
public void receiveData(Context context, int id, PebbleDictionary data) {
// Always ACKnowledge the last message to prevent timeouts
PebbleKit.sendAckToPebble(getApplicationContext(), id);
// Get action and display
int state = data.getUnsignedIntegerAsLong(Constants.SPORTS_STATE_KEY).intValue();
Toast.makeText(getApplicationContext(),
(state == Constants.SPORTS_STATE_PAUSED ? "Resumed!" : "Paused!"), Toast.LENGTH_SHORT).show();
}
};
}
PebbleKit.registerReceivedDataHandler(this, mReceiver);
}
示例13: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void receiveData(Context context, int transactionId, PebbleDictionary data) {
PebbleKit.sendAckToPebble(applicationContext, transactionId);
if (drone == null || !drone.isConnected())
return;
FollowState followMe = drone.getAttribute(AttributeType.FOLLOW_STATE);
int request = (data.getInteger(KEY_PEBBLE_REQUEST).intValue());
switch (request) {
case KEY_REQUEST_CONNECT:
//not needed. connections are expected to be made using a real GCS.
break;
case KEY_REQUEST_DISCONNECT:
//Don't do anything. Running stopSelf() would cause issues if the user changed apps and then changed back
break;
case KEY_REQUEST_MODE_FOLLOW:
if (followMe != null){
if (!followMe.isEnabled()) {
drone.enableFollowMe(followMe.getMode());
}
}
break;
case KEY_REQUEST_CYCLE_FOLLOW_TYPE:
List<FollowType> followTypes = FollowType.getFollowTypes(false);
int currentTypeIndex = followTypes.indexOf(followMe.getMode());
int nextTypeIndex = (currentTypeIndex + 1) % followTypes.size();
drone.enableFollowMe(followTypes.get(nextTypeIndex));
break;
case KEY_REQUEST_PAUSE:
if(followMe.isEnabled()){
drone.disableFollowMe();
}
drone.pauseAtCurrentLocation();
break;
case KEY_REQUEST_MODE_RTL:
drone.changeVehicleMode(VehicleMode.COPTER_RTL);
break;
}
}
示例14: onResume
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
protected void onResume()
{
super.onResume();
// The following code is for receiving commands from the pebble watch
mReceiver =
new PebbleDataReceiver(
UUID.fromString( "7d881590-feb3-4f78-af55-85bb0ebc88bd" ) )
{
@Override
public void receiveData( Context context, int
transactionId, PebbleDictionary data )
{
// ACK the message
PebbleKit.sendAckToPebble( context, transactionId );
// Check the key exists
if ( data.getUnsignedInteger( PEBBLE_PACKAGE ) != null )
{
int button =
data.getUnsignedInteger( PEBBLE_PACKAGE )
.intValue();
switch ( button )
{
case BUTTON_EVENT_UP: // The UP button was pressed
currentIndex++;
break;
case BUTTON_EVENT_DOWN: // The DOWN button was
// pressed
currentIndex--;
break;
case BUTTON_EVENT_SELECT: // The SELECT button was
// pressed
setRandomIndex();
break;
default:
// A weird signal was received
return;
}
}
doMessageUpdate();
}
};
PebbleKit.registerReceivedDataHandler( this, mReceiver );
}
示例15: receiveData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void receiveData(final Context mContext, final int transactionId, final PebbleDictionary data) {
Log.d(TAG, "Received query. data: " + data.size());
PebbleKit.sendAckToPebble(mContext, transactionId);
sendDownload(currentReading);
}