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


Java PebbleDictionary.fromJson方法代码示例

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


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

示例1: onReceive

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onReceive(final Context context, final Intent intent) {
    final UUID receivedUuid = (UUID) intent.getSerializableExtra(APP_UUID);

    // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts
    // containing their UUID
    if (!subscribedUuid.equals(receivedUuid)) {
        return;
    }

    final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1);
    final String jsonData = intent.getStringExtra(MSG_DATA);
    if (jsonData == null || jsonData.isEmpty()) {
        return;
    }

    try {
        final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
        receiveData(context, transactionId, data);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:27,代码来源:PebbleKit.java

示例2: onReceive

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onReceive(final Context context, final Intent intent) {
    final UUID receivedUuid = (UUID) intent.getSerializableExtra(APP_UUID);

    // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts
    // containing their UUID
    if (!subscribedUuid.equals(receivedUuid)) {
        return;
    }

    final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1);
    final String jsonData = intent.getStringExtra(MSG_DATA);
    if (jsonData == null || jsonData.isEmpty()) {
        return;
    }

    try {
        final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
        receiveData(context, transactionId, data);
    } catch (JSONException e) {
        e.printStackTrace();
        return;
    }
}
 
开发者ID:matejdro,项目名称:PebbleAndroidCommons,代码行数:28,代码来源:PebbleKit.java

示例3: onReceive

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onReceive(final Context context, final Intent intent) {
    final UUID receivedUuid = (UUID) intent.getSerializableExtra(APP_UUID);

    // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts containing their UUID
    if (!subscribedUuid.equals(receivedUuid)) {
        return;
    }

    final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1);
    final String jsonData = intent.getStringExtra(MSG_DATA);
    if (jsonData == null || jsonData.isEmpty()) {
        return;
    }

    try {
        final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
        receiveData(context, transactionId, data);
    } catch (JSONException e) {
        e.printStackTrace();
        return;
    }
}
 
开发者ID:smallstoneapps,项目名称:rockshot-android,代码行数:27,代码来源:PebbleKit.java

示例4: onReceive

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的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();
    }
}
 
开发者ID:C-D-Lewis,项目名称:dash-api,代码行数:30,代码来源:Receiver.java

示例5: onStartCommand

import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@Override
public int onStartCommand( final Intent intent, final int flags, final int startId )
{
	if( intent != null )
	{
		if( ACTION_STOP_RINGING.equals( intent.getAction() ) )
		{
			silencePhone( this );
		}
		else
		{
			if( Purchase.isActive( this ) )
			{
				SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences( this );
				final boolean silentMode = settings.getBoolean( Preferences.KEY_SILENT_MODE, false );

				final int transactionId = intent.getIntExtra( Constants.TRANSACTION_ID, -1 );
				final String jsonData = intent.getStringExtra( Constants.MSG_DATA );

				if( jsonData != null )
				{
					try
					{
						final long cmd;
						final PebbleDictionary data = PebbleDictionary.fromJson( jsonData );
						if( data != null )
						{
							cmd = data.getUnsignedIntegerAsLong( CMD_KEY );
						}
						else
						{
							cmd = -1;
						}

						if( cmd == CMD_START )
						{
							Log.w( TAG, "Ring Command Received!" );
							setMaxVolume( this );
							ringPhone( this, silentMode );
						}
						else if( cmd == CMD_STOP )
						{
							Log.w( TAG, "Silence Command Received!" );
							silencePhone( this );
						}
						else
						{
							Log.w( TAG, "Bad command received from pebble app: " + cmd );
						}
					}
					catch( final JSONException e )
					{
						Log.w( TAG, "failed retrieved -> dict" + e );
					}
				}
				else
				{
					Log.w( TAG, "No data from Pebble" );
				}
			}
			else
			{
				postExpiredNotification();
			}
		}
	}

	return START_NOT_STICKY;
}
 
开发者ID:Wavesonics,项目名称:RingMyPhoneAndroid,代码行数:70,代码来源:RingerService.java


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