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


Java Constant类代码示例

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


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

示例1: handleMessage

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case Constant.MSG_FROM_CLIENT:
            try {
                // 缓存数据
                cacheStepData(StepService.this,StepDcretor.CURRENT_STEP + "");
                // 更新通知栏
                updateNotification(msg.getData());
                // 回复消息给Client
                Messenger messenger = msg.replyTo;
                Message replyMsg = Message.obtain(null, Constant.MSG_FROM_SERVER);
                Bundle bundle = new Bundle();
                bundle.putInt(STEP_KEY, StepDcretor.CURRENT_STEP);
                replyMsg.setData(bundle);
                messenger.send(replyMsg);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            break;
        default:
            super.handleMessage(msg);
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:25,代码来源:StepService.java

示例2: handleMessage

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case Constant.MSG_FROM_CLIENT:
            try {
                cacheStepData(StepService.this, StepDcretor.CURRENT_STEP + "");
                updateNotification(msg.getData());
                Messenger messenger = msg.replyTo;
                Message replyMsg = Message.obtain(null, Constant.MSG_FROM_SERVER);
                Bundle bundle = new Bundle();
                bundle.putInt(STEP_KEY, StepDcretor.CURRENT_STEP);
                replyMsg.setData(bundle);
                messenger.send(replyMsg);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            break;
        default:
            super.handleMessage(msg);
    }
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:22,代码来源:StepService.java

示例3: onServiceConnected

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    try {
        messenger = new Messenger(service);
        Message msg = Message.obtain(null, Constant.MSG_FROM_CLIENT);
        msg.replyTo = replyMessenger;
        messenger.send(msg);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:12,代码来源:MainActivity.java

示例4: handleMessage

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public boolean handleMessage(Message message) {
    switch (message.what) {
        case Constant.MSG_FROM_SERVER:
            int stepCount = message.getData().getInt(StepService.STEP_KEY);
            // 更新界面上的步数
            stepCountTv.setTextColor(getResources().getColor(R.color.colorPrimary));
            stepCountTv.setText(stepCount + "");
            // 循环向服务请求数据
            delayHandler.sendEmptyMessageDelayed(Constant.REQUEST_SERVER, TIME_INTERVAL);
            break;
        case Constant.REQUEST_SERVER:
            try {
                Message serverMsg = Message.obtain(null, Constant.MSG_FROM_CLIENT);
                serverMsg.replyTo = replyMessenger;
                Bundle bundle = new Bundle();
                bundle.putSerializable(Constant.CONTENT_KEY, "今日行走");
                bundle.putSerializable(Constant.TICKER_KEY, "健客计步");
                bundle.putSerializable(Constant.CONTENTTITLE_KEY, "健客计步");
                bundle.putSerializable(Constant.PENDINGCLASS_KEY, MainActivity.class);
                bundle.putSerializable(Constant.ISONGOING_KEY, true);
                bundle.putSerializable(Constant.ICON_KEY,R.mipmap.icon);
                bundle.putSerializable(Constant.NOTIFYID_KEY, R.string.app_name);
                serverMsg.setData(bundle);
                messenger.send(serverMsg);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
    }
    return false;
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:32,代码来源:MainActivity.java

示例5: updateNotification

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
private void updateNotification(Bundle bundle) {
    if (bundle == null) {
        NotificationUtils.getInstance(StepService.this).
                updateNotification("today walk " + StepDcretor.CURRENT_STEP + " step");
    }else {
        String content = (String) bundle.getSerializable(Constant.CONTENT_KEY);
        String ticker = (String) bundle.getSerializable(Constant.TICKER_KEY);
        String contentTile = (String) bundle.getSerializable(Constant.CONTENTTITLE_KEY);
        Class pendingClass = (Class) bundle.getSerializable(Constant.PENDINGCLASS_KEY);
        boolean isOngoing = true;
        if (bundle.getSerializable(Constant.ISONGOING_KEY) != null){
            isOngoing = (boolean) bundle.getSerializable(Constant.ISONGOING_KEY);
        }
        int icon = INT_ERROR;
        if (bundle.getSerializable(Constant.ICON_KEY) != null){
            icon = (int) bundle.getSerializable(Constant.ICON_KEY);
        }
        int notifyId = INT_ERROR;
        if (bundle.getSerializable(Constant.NOTIFYID_KEY) != null){
            notifyId = (int) bundle.getSerializable(Constant.NOTIFYID_KEY);
        }
        if (StringUtil.isEmpty(content)
                || StringUtil.isEmpty(ticker)
                || StringUtil.isEmpty(contentTile)){
            NotificationUtils.getInstance(StepService.this).
                    updateNotification("today walk " + StepDcretor.CURRENT_STEP + " step");
        }else {
            NotificationUtils.getInstance(StepService.this).
                    updateNotification(content + StepDcretor.CURRENT_STEP + " step",
                            ticker,
                            contentTile,
                            StepService.this,
                            pendingClass,
                            isOngoing,
                            notifyId,
                            icon);
        }
    }
}
 
开发者ID:leibing8912,项目名称:JkstepSensorJarPack,代码行数:40,代码来源:StepService.java

示例6: onServiceConnected

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    try {
        // 向服务端发送消息(Messenger通信)
        messenger = new Messenger(service);
        Message msg = Message.obtain(null, Constant.MSG_FROM_CLIENT);
        msg.replyTo = replyMessenger;
        messenger.send(msg);
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensorDemo,代码行数:13,代码来源:MainActivity.java

示例7: handleMessage

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
@Override
public boolean handleMessage(Message message) {
    switch (message.what) {
        case Constant.MSG_FROM_SERVER:
            // 收到从服务端发来的计步数
            int stepCount = message.getData().getInt(StepService.STEP_KEY);
            // 更新界面上的步数
            mStepTipTv.setVisibility(View.VISIBLE);
            mContentTipTv.setVisibility(View.VISIBLE);
            mStepCountTv.setTextColor(getResources().getColor(cn.jianke.jkstepsensor.R.color.colorPrimary));
            mStepCountTv.setText(stepCount + "");
            // 循环向服务端请求数据
            delayHandler.sendEmptyMessageDelayed(Constant.REQUEST_SERVER, TIME_INTERVAL);
            break;
        case Constant.REQUEST_SERVER:
            try {
                // 向服务端发送消息(Messenger通信)
                Message serverMsg = Message.obtain(null, Constant.MSG_FROM_CLIENT);
                serverMsg.replyTo = replyMessenger;
                // bundle添加Notification配置信息(包括内容、标题、是否不可取消等)
                Bundle bundle = new Bundle();
                bundle.putSerializable(Constant.CONTENT_KEY, "今日行走");
                bundle.putSerializable(Constant.TICKER_KEY, "健客计步");
                bundle.putSerializable(Constant.CONTENTTITLE_KEY, "健客计步");
                bundle.putSerializable(Constant.PENDINGCLASS_KEY, MainActivity.class);
                bundle.putSerializable(Constant.ISONGOING_KEY, true);
                bundle.putSerializable(Constant.ICON_KEY, cn.jianke.jkstepsensor.R.mipmap.icon);
                bundle.putSerializable(Constant.NOTIFYID_KEY, cn.jianke.jkstepsensor.R.string.app_name);
                serverMsg.setData(bundle);
                messenger.send(serverMsg);
            } catch (RemoteException e) {
                e.printStackTrace();
            }
    }
    return false;
}
 
开发者ID:leibing8912,项目名称:JkStepSensorDemo,代码行数:37,代码来源:MainActivity.java

示例8: updateNotification

import cn.jianke.jkstepsensor.common.Constant; //导入依赖的package包/类
/**
 * 更新通知栏
 * @author leibing
 * @createTime 2016/09/02
 * @lastModify 2016/09/02
 * @param bundle 数据
 * @return
 */
private void updateNotification(Bundle bundle) {
    if (bundle == null) {
        NotificationUtils.getInstance(StepService.this).
                updateNotification("今日行走" + StepDcretor.CURRENT_STEP + "步");
    }else {
        // 内容
        String content = (String) bundle.getSerializable(Constant.CONTENT_KEY);
        // ticker
        String ticker = (String) bundle.getSerializable(Constant.TICKER_KEY);
        // 标题
        String contentTile = (String) bundle.getSerializable(Constant.CONTENTTITLE_KEY);
        // 需要跳转的Activity
        Class pendingClass = (Class) bundle.getSerializable(Constant.PENDINGCLASS_KEY);
        // 是否不可取消
        boolean isOngoing = true;
        if (bundle.getSerializable(Constant.ISONGOING_KEY) != null){
            isOngoing = (boolean) bundle.getSerializable(Constant.ISONGOING_KEY);
        }
        // 头像
        int icon = INT_ERROR;
        if (bundle.getSerializable(Constant.ICON_KEY) != null){
            icon = (int) bundle.getSerializable(Constant.ICON_KEY);
        }
        // id
        int notifyId = INT_ERROR;
        if (bundle.getSerializable(Constant.NOTIFYID_KEY) != null){
            notifyId = (int) bundle.getSerializable(Constant.NOTIFYID_KEY);
        }
        if (StringUtil.isEmpty(content)
                || StringUtil.isEmpty(ticker)
                || StringUtil.isEmpty(contentTile)){
            NotificationUtils.getInstance(StepService.this).
                    updateNotification("今日行走" + StepDcretor.CURRENT_STEP + "步");
        }else {
            NotificationUtils.getInstance(StepService.this).
                    updateNotification(content + StepDcretor.CURRENT_STEP + "步",
                            ticker,
                            contentTile,
                            StepService.this,
                            pendingClass,
                            isOngoing,
                            notifyId,
                            icon);
        }
    }
}
 
开发者ID:leibing8912,项目名称:JkStepSensor,代码行数:55,代码来源:StepService.java


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