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


Java PebbleKit.isWatchConnected方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:mathisdt,项目名称:trackworktime,代码行数:17,代码来源:ExternalNotificationManager.java

示例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;
	}
 
开发者ID:jadengore,项目名称:PebbLIFX,代码行数:22,代码来源:PebbLIFXService.java

示例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;
	}
}
 
开发者ID:mcongrove,项目名称:TitaniumPebble,代码行数:18,代码来源:TitaniumPebbleModule.java

示例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();
	}
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:27,代码来源:PebbleAppListFragment.java

示例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.");
    }


}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:41,代码来源:PebbleDisplayTrend.java

示例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();
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:15,代码来源:PebbleDisplayStandard.java

示例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;
}
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:xDrip-Experimental,代码行数:33,代码来源:PebbleSync.java

示例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);
        }
    }
}
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:NightWatch,代码行数:9,代码来源:PebbleSync.java

示例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();
    }
}
 
开发者ID:carlb15,项目名称:FunnyWordsWithPebble,代码行数:34,代码来源:MainActivity.java

示例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);
        }
    }
}
 
开发者ID:nightscout,项目名称:android-uploader,代码行数:9,代码来源:Pebble.java

示例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;
    }
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:12,代码来源:NotificationSendingModule.java

示例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);
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:55,代码来源:PebbleDisplayTrend.java

示例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);
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:71,代码来源:PebbleDisplayTrendOld.java

示例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;
         }
     }
}
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:xDrip-Experimental,代码行数:53,代码来源:PebbleSync.java

示例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;
}
 
开发者ID:firebirdberlin,项目名称:tinytimetracker,代码行数:6,代码来源:WiFiService.java


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