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


Java PebbleKit.getWatchFWVersion方法代码示例

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


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

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

示例2: getVersionInfo

import com.getpebble.android.kit.PebbleKit; //导入方法依赖的package包/类
@Kroll.method
public void getVersionInfo(HashMap args)
{
	Log.d(LCAT, "getVersionInfo");
	
	final KrollFunction successCallback = (KrollFunction)args.get("success");
	final KrollFunction errorCallback = (KrollFunction)args.get("error");
	
	int majorVersion;
	int minorVersion;
	
	try
	{
		PebbleKit.FirmwareVersionInfo versionInfo = PebbleKit.getWatchFWVersion(getApplicationContext());
		
		majorVersion = versionInfo.getMajor();
		minorVersion = versionInfo.getMinor();
	} catch(Exception e) {
		Log.w(LCAT, "Could not retrieve version info from Pebble");
		
		HashMap event = new HashMap();
		event.put("message", "Could not retrieve version info from Pebble");
		
		errorCallback.call(getKrollObject(), event);
		
		return;
	}

	Log.d(LCAT, "Pebble FW Major " + majorVersion);
	Log.d(LCAT, "Pebble FW Minor " + minorVersion);
	
	if(successCallback != null)
	{
		HashMap versionInfoHash = new HashMap();
		versionInfoHash.put("major", majorVersion);
		versionInfoHash.put("minor", minorVersion);
		
		successCallback.call(getKrollObject(), versionInfoHash);
	}
}
 
开发者ID:mcongrove,项目名称:TitaniumPebble,代码行数:41,代码来源:TitaniumPebbleModule.java

示例3: 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);
}
 
开发者ID:pebble-examples,项目名称:pebblekit-android-tutorial-1,代码行数:59,代码来源:MainActivity.java


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