Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

In this page you can find the example usage for android.os Bundle putInt.

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:air.com.snagfilms.cast.chromecast.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of
 * data in the {@link MediaInfo}. Since {@link MediaInfo} is not
 * {@link Parcelable}, one can use this container bundle to pass around from
 * one activity to another./* w  ww  .j av  a 2 s. c o  m*/
 * 
 * @see <code>toMediaInfo()</code>
 * @param info
 * @return
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }

    return wrapper;
}

From source file:io.teak.sdk.TeakNotification.java

static TeakNotification remoteNotificationFromIntent(final Context context, Intent intent) {
    final Bundle bundle = intent.getExtras();

    if (!bundle.containsKey("teakNotifId")) {
        return null;
    }/*from w  w w.j a  v a 2s.  co  m*/

    final TeakNotification ret = new TeakNotification(bundle);

    new Thread(new Runnable() {
        @Override
        public void run() {
            // Add platformId to bundle
            bundle.putInt("platformId", ret.platformId);
            // Create native notification
            Notification nativeNotification = NotificationBuilder.createNativeNotification(context, bundle,
                    ret);
            if (nativeNotification != null) {
                displayNotification(context, ret, nativeNotification);
            }
        }
    }).start();

    return ret;
}

From source file:com.google.sample.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of data in the
 * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this
 * container bundle to pass around from one activity to another.
 *
 * @param info//ww w.ja  va 2  s. c o  m
 * @return
 * @see <code>toMediaInfo()</code>
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }
    if (info.getMediaTracks() != null && !info.getMediaTracks().isEmpty()) {
        try {
            JSONArray jsonArray = new JSONArray();
            for (MediaTrack mt : info.getMediaTracks()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(KEY_TRACK_NAME, mt.getName());
                jsonObject.put(KEY_TRACK_CONTENT_ID, mt.getContentId());
                jsonObject.put(KEY_TRACK_ID, mt.getId());
                jsonObject.put(KEY_TRACK_LANGUAGE, mt.getLanguage());
                jsonObject.put(KEY_TRACK_TYPE, mt.getType());
                jsonObject.put(KEY_TRACK_SUBTYPE, mt.getSubtype());
                if (null != mt.getCustomData()) {
                    jsonObject.put(KEY_TRACK_CUSTOM_DATA, mt.getCustomData().toString());
                }
                jsonArray.put(jsonObject);
            }
            wrapper.putString(KEY_TRACKS_DATA, jsonArray.toString());
        } catch (JSONException e) {
            LOGE(TAG, "fromMediaInfo(): Failed to convert Tracks data to json", e);
        }
    }

    return wrapper;
}

From source file:com.zzl.zl_app.cache.Utility.java

public static boolean loadFile(String loadpath, String fileName, String savePath, Context context,
        String broadcastAction) {
    FileOutputStream fos = null; // ?
    FileInputStream fis = null; // ?
    InputStream is = null; // ?
    HttpURLConnection httpConnection = null;
    int readLength = 0; // ??
    int file_length = 0;
    URL url = null;//  www . j  ava 2 s . c o m
    try {
        url = new URL(loadpath);
        httpConnection = (HttpURLConnection) url.openConnection();
        httpConnection.setConnectTimeout(10000);
        httpConnection.setRequestMethod("GET");
        is = httpConnection.getInputStream();
        FileTools.creatDir(savePath);
        String filePath = savePath + fileName;
        FileTools.deleteFile(filePath);
        FileTools.creatFile(filePath);
        File download_file = new File(filePath);
        fos = new FileOutputStream(download_file, true); // ??
        fis = new FileInputStream(download_file); // ??
        int total_read = fis.available(); // ??0
        file_length = httpConnection.getContentLength(); // ?
        if (is == null) { // ?
            Tools.log("Voice", "donload failed...");
            return false;
        }
        byte buf[] = new byte[3072]; // 
        readLength = 0; // 
        Tools.log("Voice", "download start...");
        Intent startIntent = new Intent();
        Bundle b = new Bundle();
        if (broadcastAction != null) {
            // ?????
            b.putInt("fileSize", file_length);
            b.putInt("progress", 0);
            startIntent.putExtras(b);
            startIntent.setAction(broadcastAction);
            context.sendBroadcast(startIntent);
        }
        // ?????
        while (readLength != -1) {
            if ((readLength = is.read(buf)) > 0) {
                fos.write(buf, 0, readLength);
                total_read += readLength; // 
            }
            if (broadcastAction != null) {
                b.putInt("fileSize", file_length);
                b.putInt("progress", total_read);
                startIntent.putExtras(b);
                startIntent.setAction(broadcastAction);
                context.sendBroadcast(startIntent);
            }
            if (total_read == file_length) { // ?
                Tools.log("Voice", "download complete...");
                // ??????
                if (broadcastAction != null) {
                    Intent completeIntent = new Intent();
                    b.putBoolean("isFinish", true);
                    completeIntent.putExtras(b);
                    completeIntent.setAction(broadcastAction);
                    context.sendBroadcast(completeIntent);
                }

            }
            // Thread.sleep(10); // ?10
        }
    } catch (Exception e) {
        if (broadcastAction != null) {
            Intent errorIntent = new Intent();
            errorIntent.setAction(broadcastAction);
            context.sendBroadcast(errorIntent);
            e.printStackTrace();
        }
    } finally {
        try {
            if (fos != null) {
                fos.close();
            }
            if (fis != null) {
                is.close();
            }
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return true;
}

From source file:dk.kk.ibikecphlib.util.HttpUtils.java

public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) {
    Message ret = new Message();
    Bundle data = new Bundle();
    if (result != null) {
        data.putBoolean("success", result.get("success").asBoolean());
        data.putString("info", result.get("info").asText());
        if (result.has("invalid_token")) {
            if (result.get("invalid_token").asBoolean()) {
                data.putBoolean("invalid_token", result.get("invalid_token").asBoolean());
                IBikeApplication.logoutWrongToken();
            }// w  w  w  .  j a  v  a2 s.  co m
        }
        if (result != null && result.has("data")) {
            JsonNode dataNode = result.get("data");
            if (dataNode != null) {
                data.putInt("id", dataNode.get("id").asInt());
                data.putString("name", dataNode.get("name").asText());
                data.putString("email", dataNode.get("email").asText());
                if (dataNode.has("image_url"))
                    data.putString("image_url", dataNode.get("image_url").asText());
            }
        }
        ret.setData(data);
    }
    return ret;
}

From source file:com.mifos.mifosxdroid.online.LoanAccountFragment.java

public static LoanAccountFragment newInstance(int clientId) {
    LoanAccountFragment loanAccountFragment = new LoanAccountFragment();
    Bundle args = new Bundle();
    args.putInt(Constants.CLIENT_ID, clientId);
    loanAccountFragment.setArguments(args);
    return loanAccountFragment;
}

From source file:com.example.kyle.weatherforecast.FragmentAdapter.java

@Override
public Fragment getItem(int index) {
    Fragment fragment = new WeatherFragment();
    Bundle args = new Bundle();
    args.putInt("day", index);
    fragment.setArguments(args);//from w  w  w  . j  a  v  a 2s.  com
    return fragment;
}

From source file:com.cssweb.android.common.FairyUI.java

/**
 * ??\/*from w w w  .j a  va 2  s. c  o  m*/
 * 
 * @param paramInt
 * @param paramContext
 * @return
 */
public static Intent genIsLoginIntent(int paramInt, int paramInt2, Context paramContext) {
    Intent localIntent = new Intent();
    if (genIsActiveIntent(paramInt, paramInt2, paramContext)) {
        if (!TradeUtil.checkUserLogin()) {// ?
            localIntent.putExtra("menu_id", paramInt);
            localIntent.setClass(paramContext, LoginActivity.class);
        } else {
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            String orgid = TradeUser.getInstance().getOrgid();
            switch (paramInt2) {
            case Global.NJZQ_JLP_JYYH:
                localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                localIntent.putExtra("menu_id", paramInt2);
                if (1 == TradeUser.getInstance().getLoginType()) {
                    localIntent = null;
                } else {
                    localIntent.setClass(paramContext, LoginActivity.class);
                }
                break;
            case Global.NJZQ_WTJY:
                localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                localIntent.putExtra("menu_id", paramInt2);
                if (orgid == null || "".equals(orgid)) {
                    localIntent.setClass(paramContext, LoginActivity.class);
                } else {
                    localIntent.setClass(paramContext, JlpActivity.class);
                }
                break;
            case Global.NJZQ_WTJY_TWO:
                localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_THREE);
                localIntent.setClass(paramContext, FundActivity.class);
                break;
            case Global.QUOTE_USERSTK:
                localIntent.putExtra("requestType", 1);
                localIntent.setClass(paramContext, PersonalStock.class);
                break;
            case Global.QUOTE_WARNING:
            case Global.NJZQ_HQBJ_HQYJ:
                if (TradeUser.getInstance().getLoginType() == 3) {
                    localIntent.putExtra("menu_id", paramInt);
                    localIntent.setClass(paramContext, LoginActivity.class);
                } else
                    localIntent.setClass(paramContext, QuoteWarning.class);
                break;
            case Global.NJZQ_ZXHD_EGHT:
                localIntent.putExtra("menu_id", Global.NJZQ_ZXHD_EGHT);
                localIntent.setClass(paramContext, VistualTrade.class);
                break;
            case Global.QUOTE_PAIMING:
                localIntent.putExtra("requestType", 0);
                localIntent.setClass(paramContext, PaiMing.class);
                break;
            case Global.QUOTE_DAPAN:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, DaPan.class);
                break;
            case Global.NJZQ_HQBJ_QQSC_WHSC:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_QQSC_WHSC);
                localIntent.setClass(paramContext, GlobalMarket.class);
                break;
            case Global.QUOTE_FENLEI:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, FenLei.class);
                break;
            case Global.QUOTE_STOCK:
                localIntent.putExtra("type", 0);
                localIntent.setClass(paramContext, StockTypeFund.class);
                break;
            case Global.QUOTE_BOND:
                localIntent.putExtra("type", 1);
                localIntent.setClass(paramContext, StockTypeFund.class);
                break;
            case Global.QUOTE_MONETARY:
                localIntent.putExtra("type", 2);
                localIntent.setClass(paramContext, StockTypeFund.class);
                break;
            case Global.QUOTE_MIX:
                localIntent.putExtra("type", 3);
                localIntent.setClass(paramContext, StockTypeFund.class);
                break;
            case Global.SUN_PRIVATE:
                localIntent.putExtra("type", 4);
                localIntent.setClass(paramContext, SunPrivate.class);
                break;
            case Global.HK_MAINBOARD: // ?
                Bundle bundle = new Bundle();
                bundle.putInt("stocktype", 101);
                bundle.putInt("flag", 1);
                localIntent.putExtras(bundle);
                localIntent.setClass(paramContext, HKMainboard.class);
                break;
            case Global.HK_CYB: // ?
                Bundle bundle2 = new Bundle();
                bundle2.putInt("stocktype", 102);
                bundle2.putInt("flag", 2);
                localIntent.putExtras(bundle2);
                localIntent.setClass(paramContext, HKMainboard.class);
                break;

            case Global.ZJS:// 
                localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                localIntent.setClass(paramContext, ZJS.class);

                Bundle extras = new Bundle();
                extras.putString("market", "cffex");
                extras.putString("exchange", "cf");
                extras.putString("title", "");
                localIntent.putExtras(extras);
                break;
            case Global.SDZ:// ,,
                localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                localIntent.setClass(paramContext, QHSCBaseActivity.class);
                break;
            case Global.QUOTE_HSZS:
                localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                localIntent.setClass(paramContext, HSZS.class);
                break;

            case Global.QUOTE_KLINE:
                localIntent.setClass(paramContext, KLineActivity.class);
                break;
            case Global.QUOTE_FENSHI:
                localIntent.putExtra("exchange", CssSystem.exchange);
                localIntent.putExtra("stockcode", CssSystem.stockcode);
                localIntent.putExtra("stockname", CssSystem.stockname);
                localIntent.setClass(paramContext, TrendActivity.class);
                break;

            case Global.NJZQ_ZXHD_KHJL:
                localIntent.putExtra("pos", Global.NJZQ_ZXHD_KHJL);
                localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                localIntent.setClass(paramContext, WebViewDisplay.class);
                break;
            case Global.NJZQ_ZXHD_TZGW:
                if (TradeUser.getInstance().getLoginType() == 3) {
                    localIntent.putExtra("menu_id", paramInt);
                    localIntent.setClass(paramContext, LoginActivity.class);
                } else {
                    localIntent.putExtra("pos", Global.NJZQ_ZXHD_TZGW);
                    localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    localIntent.setClass(paramContext, WebViewDisplay.class);
                }
                break;
            }
        }
    } else {
        localIntent.putExtra("menu_id", paramInt);
        if (paramInt == Global.NJZQ_WTJY) {
            localIntent.putExtra("isChangeBtn", true);
        }
        localIntent.setClass(paramContext, SMSJHActivity.class);
    }
    return localIntent;
}

From source file:MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(KEY_COUNTER, mCounter);
}

From source file:com.prey.json.actions.Geofencing.java

public void stop(Context ctx, List<ActionResult> lista, JSONObject parameters) {

    Bundle bundle = new Bundle();

    bundle.putInt("type", ProxAlertActivity.STOP);

    Intent popup = new Intent(ctx, ProxAlertActivity.class);
    popup.putExtras(bundle);//ww  w .j av  a 2  s .  c  o  m
    popup.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    ctx.startActivity(popup);

    PreyLogger.i("Finish Geofencing stop");

}