當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。