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:de.ribeiro.android.gso.activities.PlanActivity.java

@SuppressLint("NewApi")
@Override//from   w  ww.j a v  a 2 s . co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ImageButton FAB;
    // Android Version prfen, wenn neuer als API11,
    Boolean actionBarAvailable = false;
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // ActionBar anfragen
        actionBarAvailable = getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    }
    _logger = new Logger(this, "PlanActivity");
    setContentView(R.layout.activity_plan);
    this.ctxt = new MyContext(this, this);

    Configuration c = getResources().getConfiguration();
    this.orientation = c.orientation;
    _logger.Info("Creating PlanActivity with orientation int: " + orientation);
    try {
        File f = new File(this.getCacheDir(), "date.bin");
        if (f.exists() && f.canRead()) {
            ctxt.mProfil.stupid.currentDate = (Calendar) FileOPs.loadObject(f);
            f.delete();
        }
    } catch (Exception e) {
        _logger.Error("An Error occurred while loading date.bin file", e);
    }

    ctxt.mProfil = new ProfilManager(ctxt).getCurrentProfil();
    ctxt.mProfil.setPrefs();
    LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
    lbm.registerReceiver(mMessageReceiver, new IntentFilter(Const.BROADCASTREFRESH));
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        int noticationId = extras.getInt("notificationId");

        if (noticationId != 0) {
            extras.remove("notificationId");
            //notication aus taskbar entfernen
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            nm.cancel(noticationId);
            Calendar date = new GregorianCalendar();
            date.setTimeInMillis(extras.getLong("date"));

            extras.remove("weekIndex");
            int profilIndex = extras.getInt("profilIndex");
            extras.remove("profilIndex");

            //alle Profile laden
            ProfilManager pm = new ProfilManager(ctxt);
            if (pm.profiles.size() >= pm.currentProfilIndex) {
                pm.profiles.get(pm.currentProfilIndex).setPrefs();
                if (profilIndex > pm.profiles.size() - 1)
                    profilIndex = 0;
                else
                    pm.currentProfilIndex = profilIndex;
                pm.applyProfilIndex();
                ctxt.mProfil.loadPrefs();
            }

            ctxt.mProfil.stupid.currentDate = date;

        }

        ctxt.newVersionReqSetup = extras.getBoolean("newVersionInfo", false);
    }

    ActionBar actionBar = getActionBar();
    if (ctxt.mIsRunning)
        actionBar.show();

    ctxt.executor.post(new PlanActivityLuncher(PlanActivity.this));

    //        FAB = (ImageButton) findViewById(R.id.imageButton);
    //        FAB.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                ctxt.getCurStupid().currentDate = new GregorianCalendar();
    //                ctxt.pager.setPage(ctxt.getCurStupid().currentDate);
    //            }
    //        });
}

From source file:com.geecko.QuickLyric.broadcastReceiver.MusicBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    /** Google Play Music
     //bool streaming            long position
     //long albumId               String album
     //bool currentSongLoaded      String track
     //long ListPosition         long ListSize
     //long id                  bool playing
     //long duration            int previewPlayType
     //bool supportsRating         int domain
     //bool albumArtFromService      String artist
     //int rating               bool local
     //bool preparing            bool inErrorState
     *//*from   w w  w  .  ja  v a  2s .c  o  m*/

    Bundle extras = intent.getExtras();
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    boolean lengthFilter = sharedPref.getBoolean("pref_filter_20min", true);

    if (extras != null)
        try {
            extras.getInt("state");
        } catch (BadParcelableException e) {
            return;
        }

    if (extras == null || extras.getInt("state") > 1 //Tracks longer than 20min are presumably not songs
            || (lengthFilter && (extras.get("duration") instanceof Long && extras.getLong("duration") > 1200000)
                    || (extras.get("duration") instanceof Double && extras.getDouble("duration") > 1200000)
                    || (extras.get("duration") instanceof Integer && extras.getInt("duration") > 1200))
            || (lengthFilter && (extras.get("secs") instanceof Long && extras.getLong("secs") > 1200000)
                    || (extras.get("secs") instanceof Double && extras.getDouble("secs") > 1200000)
                    || (extras.get("secs") instanceof Integer && extras.getInt("secs") > 1200))
            || (extras.containsKey("com.maxmpz.audioplayer.source") && Build.VERSION.SDK_INT >= 19))
        return;

    String artist = extras.getString("artist");
    String track = extras.getString("track");
    long position = extras.containsKey("position") && extras.get("position") instanceof Long
            ? extras.getLong("position")
            : -1;
    if (extras.get("position") instanceof Double)
        position = Double.valueOf(extras.getDouble("position")).longValue();
    boolean isPlaying = extras.getBoolean(extras.containsKey("playstate") ? "playstate" : "playing", true);

    if (intent.getAction().equals("com.amazon.mp3.metachanged")) {
        artist = extras.getString("com.amazon.mp3.artist");
        track = extras.getString("com.amazon.mp3.track");
    } else if (intent.getAction().equals("com.spotify.music.metadatachanged"))
        isPlaying = spotifyPlaying;
    else if (intent.getAction().equals("com.spotify.music.playbackstatechanged"))
        spotifyPlaying = isPlaying;

    if ((artist == null || "".equals(artist)) //Could be problematic
            || (track == null || "".equals(track) || track.startsWith("DTNS"))) // Ignore one of my favorite podcasts
        return;

    SharedPreferences current = context.getSharedPreferences("current_music", Context.MODE_PRIVATE);
    String currentArtist = current.getString("artist", "");
    String currentTrack = current.getString("track", "");

    SharedPreferences.Editor editor = current.edit();
    editor.putString("artist", artist);
    editor.putString("track", track);
    if (!(artist.equals(currentArtist) && track.equals(currentTrack) && position == -1))
        editor.putLong("position", position);
    editor.putBoolean("playing", isPlaying);
    if (isPlaying) {
        long currentTime = System.currentTimeMillis();
        editor.putLong("startTime", currentTime);
    }
    editor.apply();

    autoUpdate = autoUpdate || sharedPref.getBoolean("pref_auto_refresh", false);
    int notificationPref = Integer.valueOf(sharedPref.getString("pref_notifications", "0"));

    if (autoUpdate && App.isActivityVisible()) {
        Intent internalIntent = new Intent("Broadcast");
        internalIntent.putExtra("artist", artist).putExtra("track", track);
        LyricsViewFragment.sendIntent(context, internalIntent);
        forceAutoUpdate(false);
    }

    boolean inDatabase = DatabaseHelper.getInstance(context)
            .presenceCheck(new String[] { artist, track, artist, track });

    if (notificationPref != 0 && isPlaying && (inDatabase || OnlineAccessVerifier.check(context))) {
        Intent activityIntent = new Intent("com.geecko.QuickLyric.getLyrics").putExtra("TAGS",
                new String[] { artist, track });
        Intent wearableIntent = new Intent("com.geecko.QuickLyric.SEND_TO_WEARABLE").putExtra("artist", artist)
                .putExtra("track", track);
        PendingIntent openAppPending = PendingIntent.getActivity(context, 0, activityIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent wearablePending = PendingIntent.getBroadcast(context, 8, wearableIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);

        NotificationCompat.Action wearableAction = new NotificationCompat.Action.Builder(R.drawable.ic_watch,
                context.getString(R.string.wearable_prompt), wearablePending).build();

        NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
        NotificationCompat.Builder wearableNotifBuilder = new NotificationCompat.Builder(context);

        int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
                R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo,
                R.style.Theme_QuickLyric_Green, R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown,
                R.style.Theme_QuickLyric_Dark };
        int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));

        TypedValue primaryColorValue = new TypedValue();
        context.setTheme(themes[themeNum]);
        context.getTheme().resolveAttribute(R.attr.colorPrimary, primaryColorValue, true);

        notifBuilder.setSmallIcon(R.drawable.ic_notif).setContentTitle(context.getString(R.string.app_name))
                .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending)
                .setVisibility(-1) // Notification.VISIBILITY_SECRET
                .setGroup("Lyrics_Notification").setColor(primaryColorValue.data).setGroupSummary(true);

        wearableNotifBuilder.setSmallIcon(R.drawable.ic_notif)
                .setContentTitle(context.getString(R.string.app_name))
                .setContentText(String.format("%s - %s", artist, track)).setContentIntent(openAppPending)
                .setVisibility(-1) // Notification.VISIBILITY_SECRET
                .setGroup("Lyrics_Notification").setOngoing(false).setColor(primaryColorValue.data)
                .setGroupSummary(false)
                .extend(new NotificationCompat.WearableExtender().addAction(wearableAction));

        if (notificationPref == 2) {
            notifBuilder.setOngoing(true).setPriority(-2); // Notification.PRIORITY_MIN
            wearableNotifBuilder.setPriority(-2);
        } else
            notifBuilder.setPriority(-1); // Notification.PRIORITY_LOW

        Notification notif = notifBuilder.build();
        Notification wearableNotif = wearableNotifBuilder.build();

        if (notificationPref == 2)
            notif.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
        else
            notif.flags |= Notification.FLAG_AUTO_CANCEL;

        NotificationManagerCompat.from(context).notify(0, notif);
        try {
            context.getPackageManager().getPackageInfo("com.google.android.wearable.app",
                    PackageManager.GET_META_DATA);
            NotificationManagerCompat.from(context).notify(8, wearableNotif);
        } catch (PackageManager.NameNotFoundException ignored) {
        }
    } else if (track.equals(current.getString("track", "")))
        NotificationManagerCompat.from(context).cancel(0);
}

From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Bundle param;

    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        param = savedInstanceState;//from w ww .  jav a 2 s  .co m
    } else {
        param = getIntent().getExtras();
    }

    mPart = param.getInt("Part");
    mRace = param.getInt("Race");
    mLevel = param.getInt("Level");
    mJob = param.getInt("Job");
    mCurrent = param.getLong("Current");
    mAugID = param.getLong("AugId");
    mFilterID = param.getLong("Filter");
    mOrderByName = param.getBoolean("OrderByName");
    mFilterByType = param.getString("FilterByType");

    setContentView(R.layout.equipmentselector);
}

From source file:com.ichi2.anki.DeckOptions.java

@Override
protected void onCreate(Bundle icicle) {
    Themes.setThemeLegacy(this);
    super.onCreate(icicle);

    mCol = CollectionHelper.getInstance().getCol(this);
    if (mCol == null) {
        finish();/* w  w  w. j  av a  2  s. c om*/
        return;
    }
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("did")) {
        mDeck = mCol.getDecks().get(extras.getLong("did"));
    } else {
        mDeck = mCol.getDecks().current();
    }
    registerExternalStorageListener();

    if (mCol == null) {
        Timber.w("DeckOptions - No Collection loaded");
        finish();
    } else {
        mPref = new DeckPreferenceHack();
        mPref.registerOnSharedPreferenceChangeListener(this);

        this.addPreferencesFromResource(R.xml.deck_options);
        this.buildLists();
        this.updateSummaries();
        // Set the activity title to include the name of the deck
        String title = getResources().getString(R.string.deckpreferences_title);
        if (title.contains("XXX")) {
            try {
                title = title.replace("XXX", mDeck.getString("name"));
            } catch (JSONException e) {
                title = title.replace("XXX", "???");
            }
        }
        this.setTitle(title);
    }

    // Add a home button to the actionbar
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}

From source file:com.rks.musicx.ui.activities.MainActivity.java

@Override
protected void onPostResume() {
    super.onPostResume();
    if (intent != null) {
        Bundle bundle = intent.getExtras();
        if (intent.getAction().equals(SHOW_ALBUM)) {
            long id = bundle.getLong(ALBUM_ID);
            String title = bundle.getString(ALBUM_NAME);
            String artist = bundle.getString(ALBUM_ARTIST);
            int trackCount = bundle.getInt(ALBUM_TRACK_COUNT);
            Album album = new Album();
            album.setId(id);/* w w  w .  j  av  a2 s  .  c  o  m*/
            album.setArtistName(artist);
            album.setTrackCount(trackCount);
            album.setAlbumName(title);
            album.setYear(0);
            Log.e("Move", "Go_to_AlbumFrag");
            setFragment(AlbumFragment.newInstance(album));
        } else if (intent.getAction().equals(SHOW_ARTIST)) {
            long id = bundle.getLong(Constants.ARTIST_ARTIST_ID);
            String name = bundle.getString(Constants.ARTIST_NAME);
            Artist artist = new Artist(id, name, 0, 0);
            Log.e("Move", "Go_to_ArtistFrag");
            setFragment(ArtistFragment.newInstance(artist));
        } else if (intent.getAction().equals(SHOW_TAG)) {
            setFragment(TagEditorFragment.getInstance());
            Log.e("Move", "Go_to_TagFrag");
        }
        intent = null;
    }
}

From source file:com.popumovies.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d("MainActivity", "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTwoPane = getResources().getBoolean(R.bool.has_two_panes);

    mf = (MainActivityFragment) getSupportFragmentManager().findFragmentByTag(MAINFRAGMENT_TAG);
    if (mf == null)
        mf = new MainActivityFragment();
    getSupportFragmentManager().beginTransaction().replace(main_container, mf, MAINFRAGMENT_TAG).commit();

    if (savedInstanceState != null) {
        mPosition = savedInstanceState.getInt(POSITION_SAVE_KEY);
        mMovieId = savedInstanceState.getLong(MOVIE_SAVE_KEY);
        //TODO: duplicated code!!
        // Here we handle the rotation when a movie is selected
        if (mPosition >= 0 && mMovieId > 0) {
            Bundle args = new Bundle();
            if (mTwoPane) {
                if (getSupportActionBar() != null)
                    getSupportActionBar().setDisplayHomeAsUpEnabled(false);

                // in Two pane, we show the movie in the right pane
                DetailActivityFragment df = new DetailActivityFragment();
                args.putString(DetailActivityFragment.DETAIL_MOVIEID, Long.toString(mMovieId));
                df.setArguments(args);// w w  w  .  j av a 2  s .  co m

                findViewById(movie_detail_container).setVisibility(View.VISIBLE);

                getSupportFragmentManager().beginTransaction()
                        .replace(movie_detail_container, df, DETAILFRAGMENT_TAG)
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).addToBackStack(null).commit();

                mf.setPosition(mPosition);
            } else {
                // Here we handle the rotation from lands to port when a movie is selected,
                // therefore we show the ViewPager and set the correct position for the
                // Detail

                // Including the ViewPager holder (for allow nested fragments)
                ViewPagerFragment vp = new ViewPagerFragment();
                vp.setArguments(args);
                args.putInt(getString(R.string.arg_list_position_key), mPosition);

                if (getSupportActionBar() != null)
                    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

                getSupportFragmentManager().beginTransaction()
                        .replace(main_container, vp, VIEWPAGERFRAGMENT_TAG)
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).addToBackStack(null).commit();

            }
        }
    }

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setElevation(0f);
    }

}

From source file:de.incoherent.suseconferenceclient.activities.HomeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    mDialog = null;//from  w w w.  j ava 2s . c o  m

    if (savedInstanceState == null) {
        SharedPreferences settings = getSharedPreferences("SUSEConferences", 0);
        mConferenceId = settings.getLong("active_conference", -1);
    } else {
        mConferenceId = savedInstanceState.getLong("conferenceId");
        mVenueId = savedInstanceState.getLong("venueId");
    }

    if (mConferenceId == -1) {
        Log.d("SUSEConferences", "Conference ID is -1");
        if (!hasInternet()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Please enable internet access and try again.");
            builder.setCancelable(false);
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    HomeActivity.this.finish();
                }
            });
            builder.show();
        } else {
            loadConferences();
        }
    } else {
        if (savedInstanceState != null)
            setView(false);
        else
            setView(true);
    }
}

From source file:com.ushahidi.platform.mobile.app.presentation.view.ui.activity.AddPostActivity.java

private void initialize(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        mFormId = getIntent().getLongExtra(INTENT_EXTRA_PARAM_FORM_ID, 0l);
        mFormTitle = getIntent().getStringExtra(INTENT_EXTRA_PARAM_FORM_TITLE);
        initializeTagsView();//from ww w.  j  av  a  2  s .  c om
        initializeFormAttributeView();

    } else {
        mFormId = savedInstanceState.getLong(BUNDLE_STATE_PARAM_FORM_ID);
        mFormTitle = savedInstanceState.getString(BUNDLE_STATE_PARAM_FORM_TITLE);
        mFormStages = (ArrayList) savedInstanceState.getParcelableArrayList(BUNDLE_STATE_PARAM_FORM_STEPS);
        mFormAttributeModels = (ArrayList) savedInstanceState
                .getParcelableArrayList(BUNDLE_STATE_PARAM_FORM_ATTRIBUTES);
    }

    getSupportActionBar().setTitle(mFormTitle);
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Bundle param;

    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        param = savedInstanceState;//from  w  ww  .ja  v  a 2 s  .  c  om
    } else {
        param = getIntent().getExtras();
    }

    mPart = param.getInt("Part");
    mRace = param.getInt("Race");
    mLevel = param.getInt("Level");
    mJob = param.getInt("Job");
    mCurrent = param.getLong("Current");
    mAugID = param.getLong("AugId");
    mFilterID = param.getLong("Filter");
    mOrderByName = param.getBoolean("OrderByName");
    mFilterByType = param.getString("FilterByType");

    setContentView(R.layout.augmentselector);
}

From source file:com.viktorrudometkin.burramys.fragment.EntriesListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setHasOptionsMenu(true);//  w  ww.  j a v a  2 s  .c o m
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        mCurrentUri = savedInstanceState.getParcelable(STATE_CURRENT_URI);
        mOriginalUri = savedInstanceState.getParcelable(STATE_ORIGINAL_URI);
        mShowFeedInfo = savedInstanceState.getBoolean(STATE_SHOW_FEED_INFO);
        mListDisplayDate = savedInstanceState.getLong(STATE_LIST_DISPLAY_DATE);

        mEntriesCursorAdapter = new EntriesCursorAdapter(getActivity(), mCurrentUri, Constants.EMPTY_CURSOR,
                mShowFeedInfo);
    }
}