• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FenceState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
    FenceState fenceState = FenceState.extract(intent);

    if (TextUtils.equals(fenceState.getFenceKey(), COMBINE_FENCE_ENTERING_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:
                mStatusTv.setText("You are at work.");
                AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                break;
            case FenceState.FALSE:
                mStatusTv.setText("You are not at work.");
                audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
                break;
            case FenceState.UNKNOWN:
                mStatusTv.setText("Confused.:-(");
                break;
        }
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-samples,代码行数:23,代码来源:CombineFenceApiActivity.java


示例2: onHandleIntent

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
protected void onHandleIntent(Intent intent) {
    String notificationText;

    FenceState fenceState = FenceState.extract(intent);
    String fenceKey = fenceState.getFenceKey();
    if (fenceState.getCurrentState() == FenceState.TRUE) {
        StorableFenceManager manager = new StorableFenceManager(this);
        StorableFence fence = manager.getFence(fenceKey);
        if (fence != null) {
            notificationText = "(Custom)Fence " + fenceKey + " received";
        } else {
            notificationText = "(Custom)Fence " + fenceKey + " not found in store";
        }

        sendNotification(notificationText);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:18,代码来源:CustomTransitionsIntentService.java


示例3: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    if(TextUtils.equals(FENCE_RECEIVER_ACTION,intent.getAction())){    //Check if is the desired action that we are looking for
        FenceState fenceState = FenceState.extract(intent);
        switch (fenceState.getCurrentState()) {                         //Check the state info incase some error happened
            case FenceState.TRUE:
                Log.e(fenceState.getFenceKey(), "Active");

                // When new motion has been detected, output a new physical activity
                output(new AwarenessMotion(System.currentTimeMillis(), fenceState.getFenceKey()));
                break;
        }
    }
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:16,代码来源:AwarenessMotionUpdatesProvider.java


示例4: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
    FenceState fenceState = FenceState.extract(intent);

    if (TextUtils.equals(fenceState.getFenceKey(), ACTIVITY_STILL_FENCE_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:   //User is still
                mActivityFenceStatusTv.setText("You are still.");
                break;
            case FenceState.FALSE:
                mActivityFenceStatusTv.setText("You are moving. Keep moving.:-)");
                break;
            case FenceState.UNKNOWN:
                mActivityFenceStatusTv.setText("Confused.:-(");
                break;
        }
    } else if (TextUtils.equals(fenceState.getFenceKey(), ACTIVITY_MOVING_FENCE_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.FALSE:
                mActivityFenceStatusTv.setText("You are still.");
                break;
            case FenceState.TRUE: //User is moving
                mActivityFenceStatusTv.setText("You are moving. Keep moving.:-)");
                break;
            case FenceState.UNKNOWN:
                mActivityFenceStatusTv.setText("Confused.:-(");
                break;
        }
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-samples,代码行数:31,代码来源:ActivityFanceApiDemo.java


示例5: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
    FenceState fenceState = FenceState.extract(intent);

    if (TextUtils.equals(fenceState.getFenceKey(), HEADPHONE_PLUG_FENCE_KEY)) {//response if from headphone plug in fence
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:   //Head phones are plugged in. (Check fence register code)
                mHeadPhoneStatusTv.setText("Headphones connected.");
                break;
            case FenceState.FALSE:
                mHeadPhoneStatusTv.setText("Headphones disconnected.");
                break;
            case FenceState.UNKNOWN:
                mHeadPhoneStatusTv.setText("Confused.:-(");
                break;
        }
    } else if (TextUtils.equals(fenceState.getFenceKey(), HEADPHONE_UNPLUG_FENCE_KEY)) {//response if from headphone unplug fence
        switch (fenceState.getCurrentState()) {
            case FenceState.FALSE:
                mHeadPhoneStatusTv.setText("Headphones connected.");
                break;
            case FenceState.TRUE: //Head phones are unplugged. (Check fence register code)
                mHeadPhoneStatusTv.setText("Headphones disconnected.");
                break;
            case FenceState.UNKNOWN:
                mHeadPhoneStatusTv.setText("Confused.:-(");
                break;
        }
    }
}
 
开发者ID:kevalpatel2106,项目名称:android-samples,代码行数:31,代码来源:HeadphoneFenceApiActivity.java


示例6: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (!TextUtils.equals(FENCE_RECEIVER_ACTION, intent.getAction())) {
        mLogFragment.getLogView()
                .println("Received an unsupported action in FenceReceiver: action="
                        + intent.getAction());
        return;
    }

    // The state information for the given fence is em
    FenceState fenceState = FenceState.extract(intent);

    if (TextUtils.equals(fenceState.getFenceKey(), FENCE_KEY)) {
        String fenceStateStr;
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:
                fenceStateStr = "true";
                break;
            case FenceState.FALSE:
                fenceStateStr = "false";
                break;
            case FenceState.UNKNOWN:
                fenceStateStr = "unknown";
                break;
            default:
                fenceStateStr = "unknown value";
        }
        mLogFragment.getLogView().println("Fence state: " + fenceStateStr);
    }
}
 
开发者ID:googlesamples,项目名称:android-play-awareness,代码行数:31,代码来源:MainActivity.java


示例7: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    FenceState state = FenceState.extract(intent);

    Bundle bundle = intent.getBundleExtra(EXTRA_BUNDLE);

    boolean result = state.getCurrentState() == FenceState.TRUE;
    String key = state.getFenceKey();

    onUpdate(context, key, result, bundle);
}
 
开发者ID:Mauin,项目名称:ReactiveAwareness,代码行数:12,代码来源:FenceReceiver.java


示例8: subscribe

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void subscribe(ObservableEmitter<Boolean> emitter) throws Exception {
    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            FenceState state = FenceState.extract(intent);
            boolean result = state.getCurrentState() == FenceState.TRUE;
            emitter.onNext(result);
        }
    };

    context.registerReceiver(receiver, new IntentFilter(RECEIVER_ACTION));
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, fence.hashCode(), new Intent(RECEIVER_ACTION), 0);

    FenceUpdateRequest fenceUpdateRequest = new FenceUpdateRequest.Builder()
            .addFence(OBSERVABLE_FENCE, fence, pendingIntent)
            .build();

    Awareness.FenceApi.updateFences(googleApiClient, fenceUpdateRequest)
            .setResultCallback(status -> {
                if (!status.isSuccess()) {
                    emitter.onError(new ClientException("Error adding observable fence. " + status.getStatusMessage()));
                }
                emitter.onComplete();
            });

    emitter.setCancellable(() -> {
        context.unregisterReceiver(receiver);
        unregisterFenceRequest(googleApiClient, emitter);
    });
}
 
开发者ID:Mauin,项目名称:ReactiveAwareness,代码行数:32,代码来源:ObservableFence.java


示例9: onReceive

import com.google.android.gms.awareness.fence.FenceState; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    FenceState fenceState = FenceState.extract(intent);

    Log.d(TAG, "Received a Fence Broadcast");

    if (TextUtils.equals(fenceState.getFenceKey(), FenceActivity.HEADPHONE_FENCE_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are plugged in.");
                Toast.makeText(context, "Your headphones are plugged in",
                        Toast.LENGTH_LONG).show();
                break;
            case FenceState.FALSE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are NOT plugged in.");
                Toast.makeText(context, "Your headphones are NOT plugged in",
                        Toast.LENGTH_LONG).show();
                break;
            case FenceState.UNKNOWN:
                Log.i(TAG, "Received a FenceUpdate -  The headphone fence is in an unknown state.");
                break;
        }
    }
    else if (TextUtils.equals(fenceState.getFenceKey(),
            FenceActivity.HEADPHONE_AND_WALKING_FENCE_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are plugged in, AND You are walking.");
                break;
            case FenceState.FALSE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are NOT plugged in, OR You are NOT walking.");
                break;
            case FenceState.UNKNOWN:
                Log.i(TAG, "Received a FenceUpdate -  The headphone fence is in an unknown state.");
                break;
        }
    }
    else if (TextUtils.equals(fenceState.getFenceKey(),
            FenceActivity.HEADPHONE_OR_WALKING_FENCE_KEY)) {
        switch (fenceState.getCurrentState()) {
            case FenceState.TRUE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are plugged in, OR You are walking.");
                break;
            case FenceState.FALSE:
                Log.i(TAG, "Received a FenceUpdate -  Headphones are NOT plugged in, AND You are NOT walking.");
                break;
            case FenceState.UNKNOWN:
                Log.i(TAG, "Received a FenceUpdate -  The headphone/walking fence is in an unknown state.");
                break;
        }
    }
}
 
开发者ID:obaro,项目名称:UsingAwarenessAPI,代码行数:53,代码来源:FenceBroadcastReceiver.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BindingID类代码示例发布时间:2022-05-22
下一篇:
Java ParamType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap