本文整理汇总了Java中com.getpebble.android.kit.PebbleKit.isWatchConnected方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleKit.isWatchConnected方法的具体用法?Java PebbleKit.isWatchConnected怎么用?Java PebbleKit.isWatchConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.PebbleKit
的用法示例。
在下文中一共展示了PebbleKit.isWatchConnected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyPebble
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void notifyPebble(String message) {
if (PebbleKit.isWatchConnected(context)) {
final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");
final Map<String, String> data = new HashMap<String, String>();
data.put("title", "Track Work Time");
data.put("body", message);
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);
context.sendBroadcast(i);
}
}
示例2: onStartCommand
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public int onStartCommand(Intent intent, int flags, int startId) {
PebbleKit.registerReceivedDataHandler(this, new PebbleKit.PebbleDataReceiver(PEBBLE_APP_UUID) {
@Override
public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) {
Log.i("PebbLIFXService", "Received value = " + data.getUnsignedInteger(0) + " for key: 0");
if (data.getUnsignedInteger(0) == 1 && LFXClient.getSharedInstance(getApplicationContext()).getLocalNetworkContext().isConnected() == false) {
// do nothing
} else {
receiveMessage(data, transactionId);
}
}
});
boolean connected = PebbleKit.isWatchConnected(getApplicationContext());
String pebbleStatus = (connected ? "connected" : "not connected");
Toast.makeText(getApplicationContext(), "PebbLIFXService started, Pebble " + pebbleStatus , Toast.LENGTH_SHORT).show();
Log.i("PebbLIFXService", "Pebble is " + (connected ? "connected" : "not connected"));
// http://stackoverflow.com/questions/15758980/android-service-need-to-run-alwaysnever-pause-or-stop
return START_STICKY;
}
示例3: checkWatchConnected
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Kroll.method
public boolean checkWatchConnected()
{
try
{
boolean connected = PebbleKit.isWatchConnected(getApplicationContext());
if(!connected)
{
Log.w(LCAT, "checkWatchConnected: No watch connected");
}
return connected;
} catch(SecurityException e) {
return false;
}
}
示例4: retrievePebbleApps
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void retrievePebbleApps()
{
if (!PebbleKit.isWatchConnected(getActivity()))
{
new AlertDialog.Builder(getActivity()).setMessage(R.string.error_pebble_disconnected).setPositiveButton(R.string.ok, null).show();
return;
}
PebbleKit.FirmwareVersionInfo pebbleFirmwareVersion = PebbleUtil.getPebbleFirmwareVersion(getActivity());
if (pebbleFirmwareVersion != null && pebbleFirmwareVersion.getMajor() >= 3)
{
if (RootUtil.isDeviceRooted())
{
new RootAppRetrieval(getActivity(), this).retrieveApps();
}
else
{
new Sdk3AppRetrieval(getActivity(), this).retrieveApps();
}
}
else
{
new Sdk2AppRetrieval(getActivity(), this).retrieveApps();
}
}
示例5: initDisplay
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public void initDisplay(Context context, PebbleWatchSync pebbleWatchSync, BgGraphBuilder bgGraphBuilder) {
mContext = context; // just for code compatibility with xDrip experimental
super.initDisplay(context, pebbleWatchSync, bgGraphBuilder);
this.bgGraphBuilder = bgGraphBuilder;
this.pebbleWatchSync = pebbleWatchSync;
mBgReading = BgReading.last();
if (PebbleKit.isWatchConnected(mContext)) {
Log.i(TAG, "onStartCommand called. Sending Sync Request");
transactionFailed = false;
transactionOk = false;
sendStep = 5;
messageInTransit = false;
done = true;
sendingData = false;
dictionary.addInt32(SYNC_KEY, 0);
sendDataToPebble(dictionary);
dictionary.remove(SYNC_KEY);
if(!faceInactive && !watchFaceInstalled && pebble_app_version.isEmpty() && sentInitialSync){
Log.d(TAG,"onStartCommand: No watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
else if(!faceInactive && !watchFaceInstalled && !pebble_app_version.contentEquals("xDrip-Pebble2") && sentInitialSync){
Log.d(TAG,"onStartCommand: Wrong watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
else if(!faceInactive && !watchFaceInstalled && pebble_app_version.contentEquals("xDrip-Pebble2")&& sentInitialSync) {
Log.d(TAG,"onStartCommand: Watch face is installed");
watchFaceInstalled=true;
}
sentInitialSync = true;
} else {
Log.d(TAG, "onStartCommand; No watch connected.");
}
}
示例6: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload() {
if (PebbleKit.isWatchConnected(this.context)) {
PebbleDictionary dictionary = buildDictionary();
if (dictionary != null && this.context != null) {
Log.d(TAG, "sendDownload: Sending data to pebble");
sendDataToPebble(dictionary);
last_time_seen = JoH.ts();
}
} else {
watchdog();
}
}
示例7: onStartCommand
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("broadcast_to_pebble", false)) {
stopSelf();
return START_NOT_STICKY;
}
bgGraphBuilder = new BgGraphBuilder(mContext);
if(PebbleKit.isWatchConnected(mContext)) {
Log.i(TAG, "onStartCommand called. Sending Sync Request");
transactionFailed = false;
transactionOk = false;
sendStep = 5;
messageInTransit = false;
done = true;
sendingData = false;
dictionary.addInt32(SYNC_KEY, 0);
PebbleKit.sendDataToPebble(mContext, PEBBLEAPP_UUID, dictionary);
dictionary.remove(SYNC_KEY);
if(pebble_app_version.isEmpty() && sentInitialSync){
Log.d(TAG,"onStartCommand: No watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
if(!pebble_app_version.contentEquals("xDrip-Pebble2") && sentInitialSync){
Log.d(TAG,"onStartCommand: Wrong watch app version, sideloading");
sideloadInstall(mContext, WATCHAPP_FILENAME);
}
sentInitialSync = true;
} else {
Log.d(TAG,"onStartCommand; No watch connected.");
}
return START_STICKY;
}
示例8: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload(PebbleDictionary dictionary) {
if (PebbleKit.isWatchConnected(mContext)) {
if (dictionary != null && mContext != null) {
Log.d(TAG, "sendDownload: Sending data to pebble");
PebbleKit.sendDataToPebble(mContext, PEBBLEAPP_UUID, dictionary);
}
}
}
示例9: doMessageUpdate
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Sends a new word and definition to the watch and updates the textview
* within the main activity.
*/
private void doMessageUpdate()
{
// Make sure the watch is connected
if ( PebbleKit.isWatchConnected( getApplicationContext() ) )
{
// Make sure the current index is valid first
if ( currentIndex < 0 || currentIndex > wordsList.size() )
{
setRandomIndex();
}
PebbleDictionary dict = new PebbleDictionary();
dict.addString(
KEY_WORD, wordsList.get( currentIndex ) );
dict.addString( KEY_DEFINITION, definitionsList.get( currentIndex ) );
PebbleKit.sendDataToPebble( getApplicationContext(), MSG_UUID,
dict
);
txtview.setText( wordsList.get( currentIndex ) + " - "
+ definitionsList.get( currentIndex ) );
}
else
{
Toast.makeText(
getApplicationContext(),
"Warning, a pebble is not connected!",
Toast.LENGTH_LONG ).show();
}
}
示例10: sendDownload
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendDownload(PebbleDictionary dictionary) {
if (PebbleKit.isWatchConnected(context)) {
if (dictionary != null && context != null) {
Log.d(TAG, "Sending data to pebble");
PebbleKit.sendDataToPebble(context, PEBBLEAPP_UUID, dictionary);
}
}
}
示例11: isWatchConnected
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
/**
* Wrapper for PebbleKit.isWatchConnected
*/
public static boolean isWatchConnected(Context context)
{
try {
return PebbleKit.isWatchConnected(context);
} catch (Exception e) {
return false;
}
}
示例12: sendData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendData() {
final boolean online = PebbleKit.isWatchConnected(mContext);
if (online) {
if (sendStep == 5) {
sendStep = 0;
done = false;
dictionary.remove(ICON_KEY);
dictionary.remove(BG_KEY);
dictionary.remove(NAME_KEY);
dictionary.remove(BG_DELTA_KEY);
dictionary.remove(PHONE_TIME_KEY);
dictionary.remove(RECORD_TIME_KEY);
dictionary.remove(UPLOADER_BATTERY_KEY);
dictionary.remove(VIBE_KEY);
}
Log.i(TAG, "sendData: messageInTransit= " + messageInTransit + ", transactionFailed= " + transactionFailed + ", sendStep= " + sendStep);
if (sendStep == 0 && !messageInTransit && !transactionOk && !transactionFailed) {
mBgReading = BgReading.last();
sendingData = true;
buildDictionary();
sendDownload();
}
if (sendStep == 0 && !messageInTransit && transactionOk && !transactionFailed) {
Log.i(TAG, "sendData: sendStep 0 complete, clearing dictionary");
dictionary.remove(ICON_KEY);
dictionary.remove(BG_KEY);
dictionary.remove(NAME_KEY);
dictionary.remove(BG_DELTA_KEY);
dictionary.remove(PHONE_TIME_KEY);
dictionary.remove(RECORD_TIME_KEY);
dictionary.remove(UPLOADER_BATTERY_KEY);
dictionary.remove(VIBE_KEY);
transactionOk = false;
sendStep = 1;
}
if (sendStep > 0 && sendStep < 5) {
if (!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("pebble_display_trend", false)) {
sendStep = 5;
} else {
sendTrendToPebble();
}
}
if (sendStep == 5) {
sendStep = 5;
Log.i(TAG, "sendData: finished sending. sendStep = " + sendStep);
done = true;
transactionFailed = false;
transactionOk = false;
messageInTransit = false;
sendingData = false;
}
}
pebble_watchdog(online, TAG);
}
示例13: sendData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public synchronized void sendData() {
PowerManager.WakeLock wl = JoH.getWakeLock("pebble-trend-sendData",60000);
try {
if (lock.tryLock(60, TimeUnit.SECONDS)) {
try {
if (PebbleKit.isWatchConnected(this.context)) {
if (d) Log.d(TAG, "Sendstep: " + sendStep);
if (sendStep == 5) {
sendStep = 0;
done = false;
clearDictionary();
}
if (d) Log.i(TAG, "sendData: messageInTransit= " + messageInTransit + ", transactionFailed= " + transactionFailed + ", sendStep= " + sendStep);
if (sendStep == 0 && !messageInTransit && !transactionOk && !transactionFailed) {
if (use_best_glucose) {
this.dg = BestGlucose.getDisplayGlucose();
} else {
this.bgReading = BgReading.last();
}
sendingData = true;
buildDictionary();
sendDownload();
}
if (sendStep == 0 && !messageInTransit && transactionOk && !transactionFailed) {
if (d) Log.i(TAG, "sendData: sendStep 0 complete, clearing dictionary");
clearDictionary();
transactionOk = false;
sendStep = 1;
}
if (sendStep > 0 && sendStep < 5) {
if (!doWeDisplayTrendData()) {
if (didTrend) {
sendTrendToPebble(true); // clear trend image
} else {
sendStep = 5;
}
} else {
sendTrendToPebble(false);
}
}
if (sendStep == 5) {
if (d) Log.i(TAG, "sendData: finished sending. sendStep = " + sendStep);
done = true;
transactionFailed = false;
transactionOk = false;
messageInTransit = false;
sendingData = false;
}
}
} finally {
lock.unlock();
}
} else {
Log.w(TAG, "Could not acquire lock within timeout!");
}
} catch (InterruptedException e)
{
Log.w(TAG,"Got interrupted while waiting to acquire lock!");
} finally {
JoH.releaseWakeLock(wl);
}
}
示例14: sendData
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
public void sendData(){
if (PebbleKit.isWatchConnected(mContext)) {
if(sendStep == 5) {
sendStep = 0;
done=false;
dictionary.remove(ICON_KEY);
dictionary.remove(BG_KEY);
dictionary.remove(NAME_KEY);
dictionary.remove(BG_DELTA_KEY);
dictionary.remove(PHONE_TIME_KEY);
dictionary.remove(RECORD_TIME_KEY);
dictionary.remove(UPLOADER_BATTERY_KEY);
dictionary.remove(VIBE_KEY);
}
Log.i(TAG, "sendData: messageInTransit= " + messageInTransit + ", transactionFailed= " + transactionFailed + ", sendStep= " + sendStep);
if (sendStep == 0 && !messageInTransit && !transactionOk && !transactionFailed) {
mBgReading = BgReading.last();
sendingData = true;
buildDictionary();
sendDownload();
}
if (sendStep == 0 && !messageInTransit && transactionOk && !transactionFailed) {
Log.i(TAG, "sendData: sendStep 0 complete, clearing dictionary");
dictionary.remove(ICON_KEY);
dictionary.remove(BG_KEY);
dictionary.remove(NAME_KEY);
dictionary.remove(BG_DELTA_KEY);
dictionary.remove(PHONE_TIME_KEY);
dictionary.remove(RECORD_TIME_KEY);
dictionary.remove(UPLOADER_BATTERY_KEY);
dictionary.remove(VIBE_KEY);
transactionOk = false;
sendStep = 1;
}
if (sendStep > 0 && sendStep < 5) {
if(!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("pebble_display_trend",false)){
sendStep = 5;
} else {
sendTrendToPebble();
}
}
if(sendStep == 5) {
sendStep = 5;
Log.i(TAG, "sendData: finished sending. sendStep = " +sendStep);
done = true;
transactionFailed = false;
transactionOk = false;
messageInTransit = false;
sendingData = false;
}
}
}
示例15: isPebbleConnected
import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
private boolean isPebbleConnected() {
boolean connected = PebbleKit.isWatchConnected(mContext);
Log.i(TAG, "Pebble is " + (connected ? "connected" : "not connected"));
return connected;
}