Example usage for android.os Bundle putLong

List of usage examples for android.os Bundle putLong

Introduction

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

Prototype

public void putLong(@Nullable String key, long value) 

Source Link

Document

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

Usage

From source file:com.hippo.ehviewer.download.DownloadService.java

@Override
public void onStart(DownloadInfo info) {
    if (mNotifyManager == null) {
        return;//from  w  w w .ja  va 2 s . c  o m
    }

    ensureDownloadingBuilder();

    Bundle bundle = new Bundle();
    bundle.putLong(DownloadsScene.KEY_GID, info.gid);
    Intent activityIntent = new Intent(this, MainActivity.class);
    activityIntent.setAction(StageActivity.ACTION_START_SCENE);
    activityIntent.putExtra(StageActivity.KEY_SCENE_NAME, DownloadsScene.class.getName());
    activityIntent.putExtra(StageActivity.KEY_SCENE_ARGS, bundle);
    PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0, activityIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mDownloadingBuilder.setContentTitle(EhUtils.getSuitableTitle(info)).setContentText(null)
            .setContentInfo(null).setProgress(0, 0, true).setContentIntent(piActivity);

    mDownloadingDelay.startForeground();
}

From source file:com.google.appinventor.components.runtime.ProbeBase.java

protected void saveToDB(IJsonObject completeProbeUri, IJsonObject data) {

    Log.i(TAG, "Writing data: " + completeProbeUri + ": " + data.toString());
    final JsonObject dataObject = data.getAsJsonObject();
    dataObject.add("probe", completeProbeUri.get(RuntimeTypeAdapterFactory.TYPE));
    dataObject.add("timezoneOffset", new JsonPrimitive(localOffsetSeconds)); // nice
    // move//from  www.  ja  v  a  2  s  .c  om
    final long timestamp = data.get(BaseProbeKeys.TIMESTAMP).getAsLong();
    final String probeName = completeProbeUri.get("@type").getAsString();

    Bundle b = new Bundle();
    b.putString(NameValueDatabaseService.DATABASE_NAME_KEY, PROBE_BASE_NAME);
    b.putLong(NameValueDatabaseService.TIMESTAMP_KEY, timestamp);
    b.putString(NameValueDatabaseService.NAME_KEY, probeName);
    b.putString(NameValueDatabaseService.VALUE_KEY, dataObject.toString());
    Intent i = new Intent(mBoundFunfManager, NameValueDatabaseService.class);
    i.setAction(DatabaseService.ACTION_RECORD);
    i.putExtras(b);
    mBoundFunfManager.startService(i);

}

From source file:com.narkii.security.info.BaseDataFragment.java

@SuppressWarnings("deprecation")
@Override/*  ww w. j  a  v a  2 s .c  o m*/
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);
    initViews();
    initListener();
    areAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, null,
            new String[] { Area.COLUMN_NAME }, new int[] { android.R.id.text1 });
    areAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    areaSpinner.setAdapter(areAdapter);

    typeAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_spinner_item, null,
            new String[] { EnterpriseType.COLUMN_NAME }, new int[] { android.R.id.text1 });
    typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    typeSpinner.setAdapter(typeAdapter);

    getLoaderManager().initLoader(Constants.SPINNER_AREA_ID, null, this);
    getLoaderManager().restartLoader(Constants.SPINNER_ENTERPRISE_TYPE_ID, null, this);

    Log.d(TAG, "id:" + getArguments().getLong("enterpriseId", 0));
    enterpriseId = getArguments().getLong("enterpriseId", 0);
    if (enterpriseId == 0) {//

    } else {//
        Bundle bundle = new Bundle();
        bundle.putLong("id", enterpriseId);
        getLoaderManager().restartLoader(Constants.ENTERPRISE_INFO_ID, bundle, this);
        getLoaderManager().restartLoader(Constants.ENTERPRISE_PERSON_ID, bundle, this);
    }
}

From source file:com.odkclinic.client.PatientList.java

/**
 * Starts intent for viewing patientdata
 *//*w  w w  . j  a  v a2 s .com*/
private void patientDetailsIntent(long id) {
    Intent i = new Intent(this, PatientDetails.class);
    Bundle extras = new Bundle();
    extras.putLong(PatientTable.ID.getName(), id);
    i.putExtras(extras);
    startActivityForResult(i, R.layout.patientdetails);
}

From source file:org.dvbviewer.controller.ui.fragments.TimerList.java

@Override
public void onListItemClick(ListView parent, View view, int position, long id) {
    if (UIUtils.isTablet(getActivity())) {
        Timer timer = mAdapter.getItem(position);
        TimerDetails timerdetails = TimerDetails.newInstance();
        Bundle args = new Bundle();
        args.putLong(TimerDetails.EXTRA_ID, timer.getId());
        args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle());
        args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
        args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
        args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime());
        args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime());
        args.putInt(TimerDetails.EXTRA_ACTION, timer.getTimerAction());
        timerdetails.setArguments(args);
        timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName());
        onDestroyActionMode(mode);/*from   w w w  .ja v a  2  s. co m*/
    } else {
        getListView().setItemChecked(position, !getListView().isItemChecked(position));
        Timer timer = mAdapter.getItem(position);
        Intent i = new Intent(getActivity(), TimerDetailsActivity.class);
        i.putExtra(TimerDetails.EXTRA_ID, timer.getId());
        i.putExtra(TimerDetails.EXTRA_TITLE, timer.getTitle());
        i.putExtra(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName());
        i.putExtra(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId());
        i.putExtra(TimerDetails.EXTRA_START, timer.getStart().getTime());
        i.putExtra(TimerDetails.EXTRA_END, timer.getEnd().getTime());
        i.putExtra(TimerDetails.EXTRA_ACTION, timer.getTimerAction());
        startActivityForResult(i, TimerDetails.TIMER_CHANGED);
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.ViewContactActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feed_home);

    checked = new boolean[filterTypes.length];

    for (int x = 0; x < filterTypes.length; x++) {
        checked[x] = true;/*from   w w w .  j a v  a  2  s  .  c o m*/
    }

    findViewById(R.id.btn_broadcast).setVisibility(View.GONE);
    mContactId = getIntent().getLongExtra("contact_id", -1);
    if (mContactId == -1) {
        Uri data = getIntent().getData();
        if (data != null) {
            try {
                mContactId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
            }
        }
    }

    Bundle args = new Bundle();
    args.putLong("contact_id", mContactId);
    Fragment profileFragment = new ViewProfileFragment();
    profileFragment.setArguments(args);
    if (mContactId == Contact.MY_ID) {
        doTitleBar(this, "My Profile");
        mLabels.add("View");
        mLabels.add("Edit");
        mFragments.add(profileFragment);
        mFragments.add(new EditProfileFragment());

        // TODO: Legitimize this. Move objects to a randomly generated private feed
        // Ability to "move" private feeds.
        // Have a "feedPtrObj" that tracks your current private. Store in-app feed.
        Uri privateUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/private");
        mLabels.add("Notes");
        Fragment feedView = new FeedViewFragment();
        args = new Bundle(args);
        args.putParcelable(FeedViewFragment.ARG_FEED_URI, privateUri);
        feedView.setArguments(args);
        mFragments.add(feedView);
    } else {
        String title = "Profile";
        Uri feedUri = null;
        try {
            Contact contact = Contact.forId(this, mContactId).get();
            title = contact.name;
            feedUri = contact.getFeedUri();
        } catch (NoValError e) {
        }
        args.putParcelable(FeedViewFragment.ARG_FEED_URI, feedUri);
        doTitleBar(this, title);
        mLabels.add("Feed");
        mLabels.add("Apps");
        mLabels.add("Profile");
        Fragment feedView = new FeedViewFragment();
        feedView.setArguments(args);
        Fragment appView = new AppsViewFragment();
        appView.setArguments(args);

        mFragments.add(feedView);
        mFragments.add(appView);
        mFragments.add(profileFragment);

        if (MusubiBaseActivity.getInstance().isDeveloperModeEnabled()) {
            FeedView sharingView = new PresenceView();
            sharingView.getFragment().setArguments(args);
            mLabels.add(sharingView.getName());
            mFragments.add(sharingView.getFragment());
        }
    }

    PagerAdapter adapter = new ViewFragmentAdapter(getSupportFragmentManager(), mFragments);
    mViewPager = (ViewPager) findViewById(R.id.feed_pager);
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(this);

    ViewGroup group = (ViewGroup) findViewById(R.id.tab_frame);
    int i = 0;
    for (String s : mLabels) {
        Button button = new Button(this);
        button.setText(s);
        button.setTextSize(18f);

        button.setLayoutParams(CommonLayouts.FULL_HEIGHT);
        button.setTag(i++);
        button.setOnClickListener(mViewSelected);

        group.addView(button);
        mButtons.add(button);
    }

    // Listen for future changes
    Uri feedUri;
    if (mContactId == Contact.MY_ID) {
        feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/me");
    } else {
        feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts");
    }
    mProfileContentObserver = new ProfileContentObserver(mHandler);
    getContentResolver().registerContentObserver(feedUri, true, mProfileContentObserver);

    onPageSelected(0);
}

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

@Override
public void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong("viewportstart", viewPortStart);
    outState.putLong("viewportwidth", viewPortWidth);
}

From source file:com.frostwire.android.gui.dialogs.HandpickedTorrentDownloadDialog.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (outState != null && torrentInfo != null) {
        outState.putByteArray(BUNDLE_KEY_TORRENT_INFO_DATA, torrentInfo.bencode());
        outState.putString(BUNDLE_KEY_MAGNET_URI, magnetUri);
        outState.putLong(BUNDLE_KEY_TORRENT_FETCHER_DOWNLOAD_TOKEN_ID, torrentFetcherDownloadTokenId);
    }//from   w w  w  .  j a  va 2  s.  co  m
    super.onSaveInstanceState(outState); //saves the torrentInfo in bytes.
}

From source file:com.pseudosudostudios.jdd.activities.GameActivity.java

/**
 * Launches the win screen flow, including dealing with Facebook
 *//*w w w .  j  av  a2  s.  c  o  m*/
public void win(int moves) {
    new File(getFilesDir(), saveDataFileName).delete();
    Log.i("Win", "Time: " + bg.getTimeSinceStart());
    Bundle bundle = new Bundle();
    bundle.putInt(WinActivity.moveKey, moves);
    bundle.putString(WinActivity.levelKey, bg.getDifficulty().toString());
    bundle.putLong(WinActivity.timeKey, ((System.currentTimeMillis() - bg.startTime)));
    startActivityForResult(new Intent(this, WinActivity.class).putExtras(bundle), LAUNCH_WIN);
}

From source file:com.andrew.apolloMod.activities.QueryBrowserActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // Dialog doesn't allow us to wait for a result, so we need to store
    // the info we need for when the dialog posts its result
    mQueryCursor.moveToPosition(position);
    if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast()) {
        return;/* ww w .  j a v  a2s  .  c om*/
    }
    String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE));

    if ("artist".equals(selectedType)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);

        TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one);
        String artistName = tv1.getText().toString();

        Bundle bundle = new Bundle();
        bundle.putString(MIME_TYPE, Audio.Artists.CONTENT_TYPE);
        bundle.putString(ARTIST_KEY, artistName);
        bundle.putLong(BaseColumns._ID, id);

        intent.setClass(this, TracksBrowser.class);
        intent.putExtras(bundle);
        startActivity(intent);
        finish();
    } else if ("album".equals(selectedType)) {
        TextView tv1 = (TextView) v.findViewById(R.id.listview_item_line_one);
        TextView tv2 = (TextView) v.findViewById(R.id.listview_item_line_two);

        String artistName = tv2.getText().toString();
        String albumName = tv1.getText().toString();

        Bundle bundle = new Bundle();
        bundle.putString(MIME_TYPE, Audio.Albums.CONTENT_TYPE);
        bundle.putString(ARTIST_KEY, artistName);
        bundle.putString(ALBUM_KEY, albumName);
        bundle.putLong(BaseColumns._ID, id);

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(this, TracksBrowser.class);
        intent.putExtras(bundle);
        startActivity(intent);
        finish();
    } else if (position >= 0 && id >= 0) {
        long[] list = new long[] { id };
        MusicUtils.playAll(this, list, 0);
    } else {
        Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id);
    }
}