Example usage for android.os Bundle getLong

List of usage examples for android.os Bundle getLong

Introduction

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

Prototype

public long getLong(String key) 

Source Link

Document

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Usage

From source file:ca.ualberta.app.activity.CreateAnswerActivity.java

/**
 * This method will be called when the current answer is submitted, then map
 * the thread to the corresponding question and save all details into the
 * question.//from  w  ww  . j  a  va  2  s.  c o m
 * 
 * @param view
 *            View passed to the activity to check which button was pressed.
 */
public void submit_answer(View view) {
    String content = contentText.getText().toString();
    if (content.trim().length() == 0)
        noContentEntered();
    else {
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {
                long questionId = extras.getLong(QUESTION_ID);
                String questionTitle = extras.getString(QUESTION_TITLE);
                newAnswer = new Answer(content, User.author.getUserId(), imageString);
                if (addLocation == true) {
                    newAnswer.setLocationName(locationName);
                    newAnswer.setLocationCoordinates(locationCoordinates);
                }
                newAnswer.setQuestionID(questionId);
                newAnswer.setQuestionTitle(questionTitle);

                if (extras.getBoolean(EDIT_MODE)) {
                    long answerID = extras.getLong(ANSWER_ID);
                    newAnswer.setID(answerID);
                }
                if (InternetConnectionChecker.isNetworkAvailable()) {
                    Thread thread = new GetUpdateThread(questionId, newAnswer);
                    thread.start();
                } else {
                    if (extras.getBoolean(EDIT_MODE)) {
                        pushController.updateWaitingListAnswer(getApplicationContext(), newAnswer);
                    } else {
                        Toast.makeText(this,
                                "Answer added to Waiting List, it will be post when Internet is connected.",
                                Toast.LENGTH_LONG).show();
                        pushController.addWaitngListAnswers(getApplicationContext(), newAnswer, questionTitle);
                    }
                    finish();
                }
            }
        }

    }
}

From source file:com.google.android.apps.santatracker.rocketsleigh.EndGameActivity.java

private void updateAchievementsAndLeaderboard() {
    if (mGamesFragment.isSignedIn()) {
        GoogleApiClient apiClient = mGamesFragment.getGamesApiClient();
        Bundle bundle = getIntent().getExtras();

        for (int id : mAchievements) {
            String achievementStr = getString(id);
            if (bundle.containsKey(achievementStr)) {
                Games.Achievements.unlock(mGamesFragment.getGamesApiClient(), achievementStr);
                MeasurementManager.recordAchievement(mMeasurement, achievementStr,
                        getString(R.string.analytics_screen_rocket));
            }/*from w  w  w. j  a va2  s .  c o  m*/
        }

        Long score = bundle.getLong("score");
        Games.Leaderboards.submitScore(apiClient, getString(R.string.leaderboard_rocket), score);
        MeasurementManager.recordGameScore(mMeasurement, score, null,
                getString(R.string.analytics_screen_rocket));
    }
}

From source file:com.nextgis.maplibui.formcontrol.Counter.java

@Override
public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor,
        SharedPreferences preferences) throws JSONException {

    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_NAME_KEY);
    mIsShowLast = true;/*from  w w  w . j  av a 2 s.c om*/

    String value = null;
    if (null != featureCursor) { // feature exists
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0)
            value = featureCursor.getString(column);
    } else if (ControlHelper.hasKey(savedState, mFieldName)) {
        mIncremented = savedState.getLong(ControlHelper.getSavedStateKey(mFieldName));
        value = getNewValue(attributes);
    } else { // new feature
        String last = preferences.getString(mFieldName, null);
        if (last == null)
            last = attributes.getInt(JSON_INIT_VALUE_KEY) - 1 + "";

        int inc = attributes.getInt(INCREMENT);
        mIncremented = Long.valueOf(last) + inc;
        value = getNewValue(attributes);
    }

    setEnabled(false);
    setText(value);
    setSingleLine(true);
}

From source file:com.android.calendar.event.EditEventActivity.java

private EventInfo getEventInfoFromIntent(Bundle icicle) {
    EventInfo info = new EventInfo();
    long eventId = -1;
    Intent intent = getIntent();/*from w  w w  . ja  va2s . c om*/
    Uri data = intent.getData();
    if (data != null) {
        try {
            eventId = Long.parseLong(data.getLastPathSegment());
        } catch (NumberFormatException e) {
            if (DEBUG) {
                Log.d(TAG, "Create new event");
            }
        }
    } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
        eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
    }

    boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false);

    long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
    long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
    if (end != -1) {
        info.endTime = new Time();
        if (allDay) {
            info.endTime.timezone = Time.TIMEZONE_UTC;
        }
        info.endTime.set(end);
    }
    if (begin != -1) {
        info.startTime = new Time();
        if (allDay) {
            info.startTime.timezone = Time.TIMEZONE_UTC;
        }
        info.startTime.set(begin);
    }
    info.id = eventId;
    info.eventTitle = intent.getStringExtra(Events.TITLE);
    info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1);

    if (allDay) {
        info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY;
    } else {
        info.extraLong = 0;
    }
    return info;
}

From source file:com.nma.util.sdcardtrac.GraphFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    if (graphSeries != null) {
        // Restore state
        if (savedInstanceState != null) {
            viewPortStart = savedInstanceState.getLong("viewportstart");
            viewPortWidth = savedInstanceState.getLong("viewportwidth");
            redraw = true;/*ww  w .ja  v a2 s . c o  m*/
        }
        drawGraph((LinearLayout) view.findViewById(R.id.graph_fragment_layout), redraw);
    }

    // Setup navigation callbacks
    ImageButton graphFirst, graphLast, graphNext, graphPrev, graphList;
    graphFirst = (ImageButton) view.findViewById(R.id.graph_first);
    graphLast = (ImageButton) view.findViewById(R.id.graph_last);
    graphPrev = (ImageButton) view.findViewById(R.id.graph_prev);
    graphNext = (ImageButton) view.findViewById(R.id.graph_next);
    graphList = (ImageButton) view.findViewById(R.id.graph_view_list);

    graphFirst.setOnClickListener(this);
    graphLast.setOnClickListener(this);
    graphPrev.setOnClickListener(this);
    graphNext.setOnClickListener(this);
    graphList.setOnClickListener(this);
}

From source file:com.rks.musicx.ui.fragments.ArtistFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    setHasOptionsMenu(true);/* w  w  w .j a  v  a2s .  c o m*/
    if (args != null) {
        long id = args.getLong(Constants.ARTIST_ARTIST_ID);
        String name = args.getString(Constants.ARTIST_NAME);
        int albumCount = args.getInt(Constants.ARTIST_ALBUM_COUNT);
        int trackCount = args.getInt(Constants.ARTIST_TRACK_COUNT);
        artist = new Artist(id, name, albumCount, trackCount);
    }
}

From source file:com.nma.util.sdcardtrac.GraphFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);/*  w ww . j  av  a 2 s  .co m*/

    if (savedInstanceState != null) {
        viewPortStart = savedInstanceState.getLong("viewportstart");
        viewPortWidth = savedInstanceState.getLong("viewportwidth");
        redraw = true;
    }

    // Load data
    getLoaderManager().initLoader(0, null, this);
    //Log.d("Fragment:Activity", "Done with initLoader");
}

From source file:com.wly.net.PortScannerActivity.java

public static void createPacketDatagram(Bundle pktDatagram) {
    ip = new IpHeader();
    ip.setIhl(pktDatagram.getChar("ihl"));
    ip.setVer(pktDatagram.getChar("version"));
    ip.setTos(pktDatagram.getChar("tos"));
    ip.setVer(pktDatagram.getChar("ttl"));
    ip.setTos(pktDatagram.getChar("protocol"));
    ip.setTotalLen(pktDatagram.getShort("tot_len"));
    ip.setId(pktDatagram.getShort("id"));
    ip.setTotalLen(pktDatagram.getShort("frag_off"));
    ip.setIpCheck(pktDatagram.getInt("ipCheck"));
    ip.setSourceAddress(pktDatagram.getInt("saddr"));
    ip.setDestAddress(pktDatagram.getInt("daddr"));
    tcp = new TcpHeader();
    tcp.setSource(pktDatagram.getShort("source"));
    tcp.setDest(pktDatagram.getShort("dest"));
    tcp.setDoff(pktDatagram.getShort("doff"));
    tcp.setRes1(pktDatagram.getShort("res1"));
    tcp.setCwr(pktDatagram.getShort("cwr"));
    tcp.setEce(pktDatagram.getShort("ece"));
    tcp.setUrg(pktDatagram.getShort("urg"));
    tcp.setAck(pktDatagram.getShort("ack"));
    tcp.setPsh(pktDatagram.getShort("psh"));
    tcp.setRst(pktDatagram.getShort("rst"));
    tcp.setSyn(pktDatagram.getShort("syn"));
    tcp.setFin(pktDatagram.getShort("fin"));
    tcp.setWindow(pktDatagram.getShort("window"));
    tcp.setCheck(pktDatagram.getShort("check"));
    tcp.setUrgPtr(pktDatagram.getShort("urg_ptr"));
    tcp.setSeq(pktDatagram.getLong("seq"));
    tcp.setAckSeq(pktDatagram.getLong("ack_seq"));

    datagramBundle.putAll(pktDatagram);/* w  w w .  j  av a  2 s .  com*/
}

From source file:at.flack.receiver.FacebookReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    try {//ww  w . j ava 2  s  . c  o  m
        if (main instanceof FbMessageOverview && bundle.getString("type").equals("message")) {
            ((FbMessageOverview) main).addNewMessage(
                    new FacebookMessage(bundle.getString("fb_name"), bundle.getString("fb_message"),
                            bundle.getString("fb_img"), bundle.getLong("fb_id"), bundle.getString("fb_tid")));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("readreceipt")) {
            ((FbMessageOverview) main).changeReadReceipt(bundle.getLong("fb_time"),
                    bundle.getLong("fb_reader"));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("typ")) {
            ((FbMessageOverview) main).changeTypingStatus(bundle.getLong("my_id"), bundle.getLong("fb_id"),
                    bundle.getBoolean("fb_from_mobile"), bundle.getInt("fb_status"));
        } else if (main instanceof FbMessageOverview && bundle.getString("type").equals("img_message")) {
            ((FbMessageOverview) main).addNewMessage(new FacebookImageMessage(bundle.getString("fb_name"),
                    bundle.getString("fb_image"), bundle.getString("fb_preview"), bundle.getString("fb_img"),
                    bundle.getLong("fb_id"), bundle.getString("fb_tid")));
        } else if (bundle.getString("type").equals("read")) {
            killNotification(context,
                    new MarkAsRead(bundle.getString("fb_tid"), bundle.getBoolean("fb_markas")));
        } else if (bundle.getString("type").equals("message")
                || bundle.getString("type").equals("img_message")) {
            sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (!sharedPrefs.getBoolean("notification_fbs", true))
                return;
            notify = sharedPrefs.getBoolean("notifications", true);
            vibrate = sharedPrefs.getBoolean("vibration", true);
            headsup = sharedPrefs.getBoolean("headsup", true);
            led_color = sharedPrefs.getInt("notification_light", -16776961);
            boolean all = sharedPrefs.getBoolean("all_fb", true);

            if (notify == false)
                return;
            if (bundle.getLong("fb_id") == bundle.getLong("my_id")) {
                return;
            }

            NotificationCompat.Builder mBuilder = null;
            boolean use_profile_picture = false;
            Bitmap profile_picture = null;

            String origin_name = bundle.getString("fb_name");

            try {
                profile_picture = RoundedImageView.getCroppedBitmap(Bitmap.createScaledBitmap(
                        ProfilePictureCache.getInstance(context).get(origin_name), 200, 200, false), 300);
                use_profile_picture = true;
            } catch (Exception e) {
                use_profile_picture = false;
            }

            Resources res = context.getResources();

            if (bundle.getString("type").equals("img_message")) {
                bundle.putString("fb_message", res.getString(R.string.fb_notification_new_image));
            }

            int lastIndex = bundle.getString("fb_message").lastIndexOf("=");
            if (lastIndex > 0 && Base64.isBase64(bundle.getString("fb_message").substring(0, lastIndex))) {
                mBuilder = new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name)
                        .setColor(0xFF175ea2)
                        .setContentText(res.getString(R.string.sms_receiver_new_encrypted_fb))
                        .setAutoCancel(true);
                if (use_profile_picture && profile_picture != null) {
                    mBuilder = mBuilder.setLargeIcon(profile_picture);
                } else {
                    mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                            context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                }
            } else { // normal or handshake

                if (bundle.getString("fb_message").charAt(0) == '%'
                        && (bundle.getString("fb_message").length() == 10
                                || bundle.getString("fb_message").length() == 9)) {
                    if (lastIndex > 0
                            && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) {
                        mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name)
                                .setColor(0xFF175ea2)
                                .setContentText(res.getString(R.string.sms_receiver_handshake_received))
                                .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
                        if (use_profile_picture && profile_picture != null) {
                            mBuilder = mBuilder.setLargeIcon(profile_picture);
                        } else {
                            mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                    context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                        }
                    } else {
                        return;
                    }
                } else if (bundle.getString("fb_message").charAt(0) == '%'
                        && bundle.getString("fb_message").length() >= 120
                        && bundle.getString("fb_message").length() < 125) {
                    if (lastIndex > 0
                            && Base64.isBase64(bundle.getString("fb_message").substring(1, lastIndex))) {
                        mBuilder = new NotificationCompat.Builder(context).setContentTitle(origin_name)
                                .setColor(0xFF175ea2)
                                .setContentText(res.getString(R.string.sms_receiver_handshake_received))
                                .setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
                        if (use_profile_picture && profile_picture != null) {
                            mBuilder = mBuilder.setLargeIcon(profile_picture);
                        } else {
                            mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                    context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                        }
                    } else {
                        return;
                    }
                } else if (all) { // normal message
                    mBuilder = new NotificationCompat.Builder(context)
                            .setSmallIcon(R.drawable.raven_notification_icon).setContentTitle(origin_name)
                            .setColor(0xFF175ea2).setContentText(bundle.getString("fb_message"))
                            .setAutoCancel(true).setStyle(new NotificationCompat.BigTextStyle()
                                    .bigText(bundle.getString("fb_message")));

                    if (use_profile_picture && profile_picture != null) {
                        mBuilder = mBuilder.setLargeIcon(profile_picture);
                    } else {
                        mBuilder = mBuilder.setLargeIcon(convertToBitmap(origin_name,
                                context.getResources().getDrawable(R.drawable.ic_social_person), 200, 200));
                    }
                } else {
                    return;
                }
            }
            // }
            Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            mBuilder.setSound(alarmSound);
            mBuilder.setLights(led_color, 750, 4000);
            if (vibrate) {
                mBuilder.setVibrate(new long[] { 0, 100, 200, 300 });
            }

            Intent resultIntent = new Intent(context, MainActivity.class);
            resultIntent.putExtra("FACEBOOK_NAME", origin_name);

            TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
            stackBuilder.addParentStack(MainActivity.class);
            stackBuilder.addNextIntent(resultIntent);
            PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(1,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            mBuilder.setContentIntent(resultPendingIntent);
            if (Build.VERSION.SDK_INT >= 16 && headsup)
                mBuilder.setPriority(Notification.PRIORITY_HIGH);
            if (Build.VERSION.SDK_INT >= 21)
                mBuilder.setCategory(Notification.CATEGORY_MESSAGE);

            final NotificationManager mNotificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);

            if (!MainActivity.isOnTop)
                mNotificationManager.notify(8, mBuilder.build());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.dev.eth0.rssreader.app.ui.FeedEntryDetailActivity.java

@Override
protected void onCreate(Bundle pSavedInstanceState) {
    super.onCreate(pSavedInstanceState);
    // Handles screen rotation
    if (getSupportFragmentManager().findFragmentById(R.id.summary_list) != null) {
        Timber.d("Finishing as there is a summary list available");
        finish();// w  w  w.j  a v  a 2s  . c o m
        return;
    }
    fragmentStatePagerAdapter = new FeedEntryFragmentStagePagerAdapter(getSupportFragmentManager(),
            getDataHelper());
    viewPager.setAdapter(fragmentStatePagerAdapter);
    if (pSavedInstanceState != null && pSavedInstanceState.containsKey(FeedEntryTable.COLUMN_ID)) {
        feedId = pSavedInstanceState.getLong(FeedEntryTable.COLUMN_ID);
    }
    if (getIntent().getExtras() != null && getIntent().getExtras().containsKey(FeedEntryTable.COLUMN_ID)) {
        feedId = getIntent().getExtras().getLong(FeedEntryTable.COLUMN_ID);
    }
    Timber.d("onCreate show %d", feedId);
    viewPager.setCurrentItem(getDataHelper().getDataProviderHelper().getFeedEntryPositionForId(feedId));
}