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


Java DetectedActivityFence类代码示例

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


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

示例1: testValues

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@Test
public void testValues() {
    StorableActivityFence fence = StorableActivityFence.starting(
            DetectedActivityFence.IN_VEHICLE, DetectedActivityFence.RUNNING);
    int[] startActivities = {DetectedActivityFence.IN_VEHICLE, DetectedActivityFence.RUNNING};
    assertThat(fence.getType(), Matchers.is(StorableFence.Type.ACTIVITY));
    assertThat(fence.getActivityTypes(), is(startActivities));
    assertThat(fence.getTransitionType(), is(StorableActivityFence.START_TYPE));

    fence = StorableActivityFence.stopping(
            DetectedActivityFence.ON_BICYCLE, DetectedActivityFence.WALKING);
    int[] stopActivities = {DetectedActivityFence.ON_BICYCLE, DetectedActivityFence.WALKING};
    assertThat(fence.getType(), Matchers.is(StorableFence.Type.ACTIVITY));
    assertThat(fence.getActivityTypes(), is(stopActivities));
    assertThat(fence.getTransitionType(), is(StorableActivityFence.STOP_TYPE));

    fence = StorableActivityFence.during(
            DetectedActivityFence.ON_FOOT, DetectedActivityFence.STILL, DetectedActivityFence.UNKNOWN);
    int[] duringActivities = {DetectedActivityFence.ON_FOOT, DetectedActivityFence.STILL, DetectedActivityFence.UNKNOWN};
    assertThat(fence.getType(), Matchers.is(StorableFence.Type.ACTIVITY));
    assertThat(fence.getActivityTypes(), is(duringActivities));
    assertThat(fence.getTransitionType(), is(StorableActivityFence.DURING_TYPE));
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:24,代码来源:StorableActivityFenceTest.java

示例2: addHeadphoneAndLocationFence

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
private void addHeadphoneAndLocationFence() {
        Intent intent = new Intent(MY_FENCE_RECEIVER_ACTION);
        PendingIntent mFencePendingIntent = PendingIntent.getBroadcast(FenceActivity.this,
                10001,
                intent,
                0);

        AwarenessFence headphoneFence = HeadphoneFence.during(HeadphoneState.PLUGGED_IN);
        AwarenessFence activityFence = DetectedActivityFence.during(DetectedActivityFence.WALKING);
        AwarenessFence jointFence = AwarenessFence.and(headphoneFence, activityFence);
        Awareness.FenceApi.updateFences(
                mGoogleApiClient,
                new FenceUpdateRequest.Builder()
                        .addFence(HEADPHONE_AND_WALKING_FENCE_KEY,
                                jointFence, mFencePendingIntent)
                        .build())
                .setResultCallback(new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        if (status.isSuccess()) {
                            Log.i(TAG, "Headphones AND Walking Fence was successfully registered.");
                        } else {
                            Log.e(TAG, "Headphones AND Walking Fence could not be registered: " + status);
                        }
                    }
                });
}
 
开发者ID:obaro,项目名称:UsingAwarenessAPI,代码行数:28,代码来源:FenceActivity.java

示例3: provide

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@Override
    protected void provide() {
        Thread thread = Thread.currentThread();
        Thread.UncaughtExceptionHandler wrapped = thread.getUncaughtExceptionHandler();
        if (!(wrapped instanceof GoogleApiFixUncaughtExceptionHandler)) {
            GoogleApiFixUncaughtExceptionHandler handler = new GoogleApiFixUncaughtExceptionHandler(wrapped);
            thread.setUncaughtExceptionHandler(handler);
        }
//        Thread thread = Thread.currentThread();
//        thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
//            @Override
//            public void uncaughtException(Thread thread, Throwable throwable) {
//                System.out.println(thread.getName() + " throws exception: " + throwable);
//            }
//        });

            client = new GoogleApiClient.Builder(getContext())                              //Establish Connection
                    .addApi(Awareness.API)
                    .build();
            client.connect();
            walkingFence = DetectedActivityFence.during(DetectedActivityFence.WALKING);     //Create Fence
            onFootFence = DetectedActivityFence.during(DetectedActivityFence.ON_FOOT);
            runningFence = DetectedActivityFence.during(DetectedActivityFence.RUNNING);

            intent = new Intent(FENCE_RECEIVER_ACTION);                                     //Set up the intent and intent filter
            myFillter = new IntentFilter(FENCE_RECEIVER_ACTION);
            myPendingIntent = PendingIntent.getBroadcast(getContext(), 0, intent, 0);           //Set up the pendingIntent
            myFenceReceiver = new FenceReceiver();                                              //Set up the receiver
            getContext().registerReceiver(myFenceReceiver, myFillter);
            registerFence(WALKINGFENCE, walkingFence);                                       //register the fences
            registerFence(TILTINGFENCE, tiltingFence);
            registerFence(ONFOOTFENCE, onFootFence);
            registerFence(RUNNINGFENCE, runningFence);
    }
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:35,代码来源:AwarenessMotionUpdatesProvider.java

示例4: onWalkingClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onWalkingClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.WALKING)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.WALKING));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.WALKING);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例5: onRunningClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onRunningClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.RUNNING)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.RUNNING));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.RUNNING);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例6: onDrivingClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onDrivingClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.IN_VEHICLE)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.IN_VEHICLE));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.IN_VEHICLE);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例7: onBicyclingClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onBicyclingClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.ON_BICYCLE)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.ON_BICYCLE));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.ON_BICYCLE);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例8: onStillClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onStillClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.STILL)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.STILL));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.STILL);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例9: onFootClicked

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public void onFootClicked(View view) {
    if (mActivityType.contains(DetectedActivityFence.ON_FOOT)) {
        mActivityType.remove(Integer.valueOf(DetectedActivityFence.ON_FOOT));
        view.setBackgroundColor(Color.LTGRAY);
    } else {
        mActivityType.add(DetectedActivityFence.ON_FOOT);
        view.setBackgroundColor(Color.WHITE);
    }
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:10,代码来源:FenceChooserActivity.java

示例10: getAwarenessFence

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@RequiresPermission("com.google.android.gms.permission.ACTIVITY_RECOGNITION")
@Override
AwarenessFence getAwarenessFence(Context ctx) {
    switch (mTransitionType) {
        case DURING_TYPE:
            return DetectedActivityFence.during(mActivityTypes);
        case START_TYPE:
            return DetectedActivityFence.starting(mActivityTypes);
        case STOP_TYPE:
            return DetectedActivityFence.stopping(mActivityTypes);
    }
    return null;
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:14,代码来源:StorableActivityFence.java

示例11: setUp

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mStore = new FenceStore(mContext, "test");
    mAct1 = StorableActivityFence.starting(DetectedActivityFence.IN_VEHICLE);
    mAct2 = StorableActivityFence.during(DetectedActivityFence.RUNNING);
    mLoc1 = StorableLocationFence.entering(2, 3, 30);
    mLoc2 = StorableLocationFence.exiting(3, 4, 40);
    mAnd = StorableFence.and(mAct1, mAct2);
    mNot = StorableFence.or(mLoc1);
    mOr = StorableFence.or(mNot, mAnd, mLoc2);
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:12,代码来源:FenceStoreTest.java

示例12: setUp

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    mAct1 = StorableActivityFence.starting(DetectedActivityFence.IN_VEHICLE);
    mAct1.setPendingIntentClass("className");
    mAct2 = StorableActivityFence.during(DetectedActivityFence.RUNNING);
    mLoc1 = StorableLocationFence.entering(2, 3, 30);
    mLoc1.setId("1");
    mLoc2 = StorableLocationFence.exiting(3, 4, 40);
    mHead1 = StorableHeadphoneFence.during(HeadphoneState.PLUGGED_IN);
    mTime1 = StorableTimeFence.inFridayInterval(TimeZone.getDefault(), 20, 20000);

}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:15,代码来源:StorableFenceTest.java

示例13: testEquals

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
@Test
public void testEquals() {
    StorableActivityFence fence1 = StorableActivityFence.starting(
            DetectedActivityFence.IN_VEHICLE, DetectedActivityFence.RUNNING);
    StorableActivityFence fence2 = StorableActivityFence.stopping(
            DetectedActivityFence.ON_BICYCLE, DetectedActivityFence.WALKING);
    StorableActivityFence fence3 = StorableActivityFence.stopping(
            DetectedActivityFence.ON_BICYCLE, DetectedActivityFence.WALKING);

    assertThat(fence1.equals(fence1), is(true));
    assertThat(fence2.equals(fence3), is(true));
    assertThat(fence3.equals(null), is(false));
    assertThat(fence3.equals(fence1), is(false));
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:15,代码来源:StorableActivityFenceTest.java

示例14: addHeadphoneOrLocationFence

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
private void addHeadphoneOrLocationFence() {
    Intent intent = new Intent(MY_FENCE_RECEIVER_ACTION);
    PendingIntent mFencePendingIntent = PendingIntent.getBroadcast(FenceActivity.this,
            10001,
            intent,
            0);

    AwarenessFence headphoneFence = HeadphoneFence.during(HeadphoneState.PLUGGED_IN);
    AwarenessFence activityFence = DetectedActivityFence.during(DetectedActivityFence.WALKING);

    AwarenessFence orFence = AwarenessFence.or(headphoneFence, activityFence);
    Awareness.FenceApi.updateFences(
            mGoogleApiClient,
            new FenceUpdateRequest.Builder()
                    .addFence(HEADPHONE_OR_WALKING_FENCE_KEY,
                            orFence, mFencePendingIntent)
                    .build())
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    if (status.isSuccess()) {
                        Log.i(TAG, "Headphones OR Walking Fence was successfully registered.");
                    } else {
                        Log.e(TAG, "Headphones OR Walking Fence could not be registered: " + status);
                    }
                }
            });
}
 
开发者ID:obaro,项目名称:UsingAwarenessAPI,代码行数:29,代码来源:FenceActivity.java

示例15: getFenceStr

import com.google.android.gms.awareness.fence.DetectedActivityFence; //导入依赖的package包/类
public String getFenceStr(StorableFence fence) {
    String str = "";
    switch (fence.getType()) {
        case ACTIVITY:
            for (@StorableActivityFence.ActivityType int act : ((StorableActivityFence) fence).getActivityTypes()) {
                if (!str.isEmpty()) {
                    str += ", ";
                }
                switch (act) {
                    case DetectedActivityFence.IN_VEHICLE:
                        str += "IN_VEHICLE";
                        break;
                    case DetectedActivityFence.ON_BICYCLE:
                        str += "ON_BICYCLE";
                        break;
                    case DetectedActivityFence.ON_FOOT:
                        str += "ON_FOOT";
                        break;
                    case DetectedActivityFence.RUNNING:
                        str += "RUNNING";
                        break;
                    case DetectedActivityFence.STILL:
                        str += "STILL";
                        break;
                    case DetectedActivityFence.WALKING:
                        str += "WALKING";
                        break;
                    case DetectedActivityFence.UNKNOWN:
                    default:
                        str += "UNKNOWN";
                        break;
                }
            }
            break;
        case LOCATION:
            StorableLocationFence locFence = (StorableLocationFence) fence;
            str += "(" + locFence.getLatitude() + ", " + locFence.getLongitude() + ") ";
            break;
        default:
            break;
    }
    return str;
}
 
开发者ID:djavan-bertrand,项目名称:JCVD,代码行数:44,代码来源:FenceRecyclerAdapter.java


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