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


Java PebbleKit类代码示例

本文整理汇总了Java中com.getpebble.android.kit.PebbleKit的典型用法代码示例。如果您正苦于以下问题:Java PebbleKit类的具体用法?Java PebbleKit怎么用?Java PebbleKit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PebbleKit类属于com.getpebble.android.kit包,在下文中一共展示了PebbleKit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendForecast

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
private void sendForecast()
{
    Collections.sort(m_forecast);
    int utcOffset = TimeZone.getDefault().getRawOffset();
    long startOfToday = getStartOfDay().getTime();
    long minutesSinceStartOfToday = (Calendar.getInstance().getTime().getTime() - startOfToday) / 60000;
    for (Forecast f : m_forecast) {
        if (m_nackCount > 5)
            return;
        long minInFuture = (f.getTimeFrom().getTime() - startOfToday + utcOffset) / 60000;
        // 172px, 1 px per half-hour period = 5160 minutes; but
        // minInFuture is from startOfToday so we usually need to go higher than 5160
        if (minInFuture - minutesSinceStartOfToday < 5200 && f.getTemperature() != null) {
            PebbleDictionary out = new PebbleDictionary();
            out.addInt16(KEY_FORECAST_MINUTES, (short)minInFuture);
            out.addInt16(KEY_FORECAST_TEMPERATURE, (short)Math.round(f.getTemperature().getTemperatureDouble() * 10));
            // TODO add wind speed? what else?
            PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
            try {
                Thread.sleep(SLEEP_BETWEEN_PACKETS);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:ec1oud,项目名称:sologyr,代码行数:27,代码来源:PebbleUtil.java

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

示例3: sendStartAppOnPebble

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
/**
 * Pebbleアプリに起動依頼を送信後、数秒した後にrunを実行する.
 * <p>
 * この関数は、別スレッドで動作するので、他の関数とは違う挙動をする。<br/>
 * なので、この関数を使用する場合には、考慮する必要が有る。
 * </p>
 * @param run 起動後に実行する処理
 */
private void sendStartAppOnPebble(final Runnable run) {
    final int sleepMilliSec = 2000;
    new Thread(new Runnable() {
        @Override
        public void run() {
            PebbleKit.startAppOnPebble(getContext(), MY_UUID);
            try {
                Thread.sleep(sleepMilliSec);
                run.run();
            } catch (InterruptedException e) {
                return;
            }
        }
    }).start();
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:24,代码来源:PebbleManager.java

示例4: getPebbleFirmwareVersion

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
public static @Nullable PebbleKit.FirmwareVersionInfo getPebbleFirmwareVersion(Context context)
{
    /**
     * For some reason this method in PebbleKit keeps throwing exceptions.
     * Lets wrap it in try/catch.
     */

    try
    {
        return PebbleKit.getWatchFWVersion(context);
    }
    catch (Exception e)
    {
        return null;
    }
}
 
开发者ID:matejdro,项目名称:PebbleAndroidCommons,代码行数:17,代码来源:PebbleUtil.java

示例5: init

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
private void init() {
    Log.i(TAG, "Initialising...");
    Log.i(TAG, "configuring PebbleDataReceiver");

    PebbleKit.registerReceivedDataHandler(mContext, new PebbleKit.PebbleDataReceiver(PEBBLEAPP_UUID) {
        @Override
        public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) {
            Log.d(TAG, "receiveData: transactionId is " + String.valueOf(transactionId));
            if (lastTransactionId == 0 || transactionId != lastTransactionId) {
                lastTransactionId = transactionId;
                Log.d(TAG, "Received Query. data: " + data.size() + ". sending ACK and data");
                PebbleKit.sendAckToPebble(context, transactionId);
                sendData();
            } else {
                Log.d(TAG, "receiveData: lastTransactionId is "+ String.valueOf(lastTransactionId)+ ", sending NACK");
                PebbleKit.sendNackToPebble(context,transactionId);
            }
        }
    });
}
 
开发者ID:StephenBlackWasAlreadyTaken,项目名称:NightWatch,代码行数:21,代码来源:PebbleSync.java

示例6: onCreate

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
@Override
public void onCreate(){
    super.onCreate();
    applicationContext = getApplicationContext();
    pebbleDataHandler = new PebbleReceiverHandler(DP_UUID);
    PebbleKit.registerReceivedDataHandler(applicationContext, pebbleDataHandler);
    PebbleKit.registerReceivedAckHandler(applicationContext, new PebbleKit.PebbleAckReceiver(DP_UUID) {
        @Override
        public void receiveAck(Context context, int transactionId) {//Did pebble receive last msg?
            safeToSendNextPacketToPebble = true;
        }
    });

    controlTower = new ControlTower(applicationContext);
    this.drone = new Drone();
}
 
开发者ID:DroidPlanner,项目名称:tower-pebble,代码行数:17,代码来源:PebbleCommunicatorService.java

示例7: startWatchApp

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
/**
    * Attempt to start the pebble_sd watch app on the pebble watch.
    */
   public void startWatchApp() {
       Log.v(TAG, "startWatchApp() - closing app first");
       mUtil.writeToSysLogFile("SdDataSourcePebble.startWatchApp() - closing app first");
       // first close the watch app if it is running.
       PebbleKit.closeAppOnPebble(mContext, SD_UUID);
       Log.v(TAG, "startWatchApp() - starting watch app after 5 seconds delay...");
// Wait 5 seconds then start the app.
       Timer appStartTimer = new Timer();
       appStartTimer.schedule(new TimerTask() {
           @Override
           public void run() {
               Log.v(TAG, "startWatchApp() - starting watch app...");
               mUtil.writeToSysLogFile("SdDataSourcePebble.startWatchApp() - starting watch app");
               PebbleKit.startAppOnPebble(mContext, SD_UUID);
           }
       }, 5000);
   }
 
开发者ID:OpenSeizureDetector,项目名称:Android_Pebble_SD,代码行数:21,代码来源:SdDataSourcePebble.java

示例8: 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

示例9: onDestroy

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
/**
 * Closes the text file of words.
 */
@Override
protected void onDestroy()
{
    super.onDestroy();
    try
    {
        in.close();
    }
    catch ( IOException e )
    {
        e.printStackTrace();
    }

    if ( null != mReceiver )
    {
        unregisterReceiver( mReceiver );
    }

    PebbleKit.closeAppOnPebble( getApplicationContext(), MSG_UUID );
}
 
开发者ID:carlb15,项目名称:FunnyWordsWithPebble,代码行数:24,代码来源:MainActivity.java

示例10: 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

示例11: 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

示例12: onCreate

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_microwave_client);
    
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new MicrowaveClientFragment())
                .commit();
    }
    
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }
    
    PebbleKit.startAppOnPebble(this, PEBBLE_APP_UUID);
}
 
开发者ID:kashev,项目名称:nextWAVE,代码行数:19,代码来源:MicrowaveClientActivity.java

示例13: PebbleCommunication

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param applicationContext the Context in which we works.
 */
public PebbleCommunication(Context applicationContext) {
	mContext = applicationContext;
	messageManager = new MessageManager(mContext, APP_UUID);
	mContainer = TrafficsenseContainer.getInstance();
	// The thread is started in startAppOnPebble()
	PebbleKit.registerReceivedDataHandler(mContext, new PebbleKit.PebbleDataReceiver(APP_UUID) {
		@Override
		public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) {
			if (data.getUnsignedInteger(KEY_COMMAND) == PEBBLE_COMMAND_GET) {
				// Information requested from Pebble
				if (mContainer.getPebbleUiController() != null && mContainer.isJourneyStarted()) {
					mContainer.getPebbleUiController().totalUpdate();
				}
				PebbleKit.sendAckToPebble(mContext, transactionId);
			} else {
				// Not ready to send anything, send nack
				PebbleKit.sendNackToPebble(mContext, transactionId);
			}
		}
	});
	mMessageManagerThread = new Thread(messageManager);
}
 
开发者ID:apps8os,项目名称:trafficsense,代码行数:28,代码来源:PebbleCommunication.java

示例14: consumeAsync

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
/**
 * Consume and send a message to Pebble.
 */
private void consumeAsync() {
	messageHandler.post(new Runnable() {
		@Override
		public synchronized void run() {
			if (isMessagePending.booleanValue()) {
				return;
			}
			if (messageQueue.size() == 0) {
				return;
			}

			// DBG stuff
			long command = messageQueue.peek().getUnsignedInteger(0);
			System.out.println("DBG MessageManager sent dict to Pebble with command " + command);

			PebbleKit.sendDataToPebble(mContext.getApplicationContext(), mUUID, messageQueue.peek());
			isMessagePending = Boolean.valueOf(true);
		}
	});
}
 
开发者ID:apps8os,项目名称:trafficsense,代码行数:24,代码来源:MessageManager.java

示例15: sendNativeNotification

import com.getpebble.android.kit.PebbleKit; //导入依赖的package包/类
private void sendNativeNotification(ProcessedNotification notification)
{
    Timber.d("Sending native notification...");

    notification.nativeNotification = true;

    PebbleKit.FirmwareVersionInfo watchfirmware = PebbleUtil.getPebbleFirmwareVersion(getService());
    if (watchfirmware == null)
    {
        return;
    }

    if (watchfirmware.getMajor() > 2)
    {
        NotificationCenterDeveloperConnection.fromDevConn(getService().getDeveloperConnection()).sendSDK3Notification(notification, true);
    }
    else if (watchfirmware.getMajor() == 2 && watchfirmware.getMinor() > 8)
    {
        NotificationCenterDeveloperConnection.fromDevConn(getService().getDeveloperConnection()).sendNotification(notification);
    }
    else
    {
        getService().getDeveloperConnection().sendBasicNotification(notification.source.getText(), notification.source.getSubtitle() + "\n" + notification.source.getText());
    }

}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:27,代码来源:NotificationSendingModule.java


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