Example usage for android.os Bundle getStringArray

List of usage examples for android.os Bundle getStringArray

Introduction

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

Prototype

@Nullable
public String[] getStringArray(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:edu.cnu.PowerTutor.ui.PowerViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    uid = getIntent().getIntExtra("uid", SystemInfo.AID_ALL);

    collecting = true;//from  w  w  w .j  av a 2 s  . c  om
    if (savedInstanceState != null) {
        collecting = savedInstanceState.getBoolean("collecting", true);
        componentNames = savedInstanceState.getStringArray("componentNames");
        noUidMask = savedInstanceState.getInt("noUidMask");
    }

    serviceIntent = new Intent(this, UMLoggerService.class);
    conn = new CounterServiceConnection();
}

From source file:com.nishithkumar.popularmovies.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_main);

    movieIds = new String[20];
    lastSelection = "TOP_RATED";

    Log.d(TAG, "onCreate! ");

    /* If saved last selection populate it */
    sharedPref = getPreferences(Context.MODE_PRIVATE);
    lastSelection = sharedPref.getString("SELECTION", "TOP_RATED");

    gridView = (GridView) findViewById(R.id.gridview);
    mImageAdapter = new ImageAdapter(this, movieIds);
    gridView.setAdapter(mImageAdapter);/* www  . ja  v a2 s . c  o m*/

    if (savedInstanceState != null) {
        //get your data saved and populate the adapter here
        movieIds = savedInstanceState.getStringArray("MOVIES");
        mImageAdapter.updateGrid(movieIds);
        mImageAdapter.notifyDataSetChanged();
        Log.d(TAG, "Restore savedInstanceState : Retrieve Movie List!");
    } else {

        Log.d(TAG, "savedInstanceState is Null!");

        //Start background task to download Movie list
        FetchMoviesTask fetchMoviesTask = new FetchMoviesTask();
        fetchMoviesTask.execute(lastSelection);
    }

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            JSONObject movieDetails = null;
            String title = null;
            String poster = null;
            String plot = null;
            String releaseDate = null;
            String voteAverage = null;

            try {
                movieDetails = resultsArray.getJSONObject(position);
                title = movieDetails.getString("title");
                poster = movieIds[position];
                plot = movieDetails.getString("overview");
                releaseDate = movieDetails.getString("release_date");
                voteAverage = movieDetails.getString("vote_average");

            } catch (Exception e) {
                e.printStackTrace();
            } finally {

            }

            if (movieDetails != null) {
                Intent detailsIntent = new Intent(getApplicationContext(), MovieDetails.class);
                detailsIntent.putExtra("movie_title", title);
                detailsIntent.putExtra("movie_poster", poster);
                detailsIntent.putExtra("movie_plot", plot);
                detailsIntent.putExtra("movie_release_date", releaseDate);
                detailsIntent.putExtra("movie_vote_average", voteAverage);
                startActivity(detailsIntent);
            }

        } //end function
    });

}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddTimeAlertFragment.java

/**
 * {@inheritDoc}//from w  w w .j a va2  s  .co  m
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get the various resources.
    final Context context = getActivity().getApplicationContext();
    bsd = BusStopDatabase.getInstance(context);
    alertMan = AlertManager.getInstance(context);

    final Bundle args = getArguments();
    // Get the stop code from the arguments.
    stopCode = args.getString(ARG_STOPCODE);

    // Make sure a stopcode exists.
    if (stopCode == null || stopCode.length() == 0)
        throw new IllegalArgumentException("A stop code must be " + "supplied.");

    services = bsd.getBusServicesForStop(stopCode);

    if (savedInstanceState != null) {
        selectedServices = savedInstanceState.getStringArray(ARG_SELECTED_SERVICES);
    } else {
        selectedServices = args.getStringArray(ARG_DEFAULT_SERVICES);
    }
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWidget.java

@Override
public void onHandleMessage(Message message) {
    if (message == null) {
        return;/*  ww  w. ja v a2s .  c o m*/
    }
    Bundle bundle = message.getData();
    switch (message.what) {
    case MSG_IS_APP_INSTALLED:
        isAppInstalledMsg(bundle.getStringArray(BUNDLE_DATA));
        break;
    case MSG_RELOAD_WIDGET_BY_APPID:
        reloadWidgetByAppIdMsg(bundle.getStringArray(BUNDLE_DATA));
        break;
    default:
        super.onHandleMessage(message);
    }
}

From source file:com.silentcircle.contacts.list.ScContactEntryListAdapter.java

/**
 * Updates the indexer, which is used to produce section headers.
 *///w  ww .  ja  v  a2 s  .  c  o  m
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void updateIndexer(Cursor cursor) {
    if (cursor == null) {
        setIndexer(null);
        return;
    }
    Bundle bundle = cursor.getExtras();

    if (bundle == Bundle.EMPTY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) // try the dirty trick
        bundle = mContext.getContentResolver().call(ScContactsContract.AUTHORITY_URI, "INDEX", null, null);

    if (bundle != null
            && bundle.containsKey(ScContactsContract.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES)) {
        String sections[] = bundle
                .getStringArray(ScContactsContract.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
        int counts[] = bundle.getIntArray(ScContactsContract.ContactCounts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
        setIndexer(new ContactsSectionIndexer(sections, counts));
    } else {
        setIndexer(null);
    }
}

From source file:eu.alefzero.owncloud.ui.activity.FileDisplayActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().toString(), "onCreate() start");
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));

    if (savedInstanceState != null) {
        mDirs = savedInstanceState.getStringArray(KEY_DIR_ARRAY);
        mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
        mDirectories.add(OCFile.PATH_SEPARATOR);
        if (mDirs != null)
            for (String s : mDirs)
                mDirectories.insert(s, 0);
        mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
    }/* www. ja va2s  . c om*/

    mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once!

    if (AccountUtils.accountsAreSetup(this)) {

        initDelayedTilAccountAvailabe();

        // PIN CODE request ;  best location is to decide, let's try this first
        //if (savedInstanceState == null) {
        if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN)
                && savedInstanceState == null) {
            requestPinCode();
        }

    } else {

        setContentView(R.layout.no_account_available);
        getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);
        findViewById(R.id.setup_account).setOnClickListener(this);

        setSupportProgressBarIndeterminateVisibility(false);

        Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
        intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES,
                new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
        startActivity(intent); // although the code is here, the activity won't be created until this.onStart() and this.onResume() are finished;
        mForcedLoginToCreateFirstAccount = true;
    }

    Log.i(getClass().toString(), "onCreate() end");
}

From source file:com.ultramegasoft.flavordex2.fragment.EntryListFragment.java

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Bundle args = getArguments();
    mCatId = args != null ? args.getLong(ARG_CAT, mCatId) : mCatId;
    mTwoPane = args != null && args.getBoolean(ARG_TWO_PANE, mTwoPane);
    mActivatedItem = args != null ? args.getLong(ARG_SELECTED_ITEM, mActivatedItem) : mActivatedItem;
    mWhere = args != null ? args.getString(ARG_WHERE) : null;
    mWhereArgs = args != null ? args.getStringArray(ARG_WHERE_ARGS) : null;
    mExportMode = args != null && args.getBoolean(ARG_EXPORT_MODE, mExportMode);

    if (savedInstanceState != null) {
        mActivatedItem = savedInstanceState.getLong(STATE_SELECTED_ITEM, mActivatedItem);
        mExportMode = savedInstanceState.getBoolean(STATE_EXPORT_MODE, mExportMode);
    }/*from  w  ww .  j  ava  2 s . c o  m*/

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
    mSortField = prefs.getString(FlavordexApp.PREF_LIST_SORT_FIELD, mSortField);
    mSortReversed = prefs.getBoolean(FlavordexApp.PREF_LIST_SORT_REVERSED, mSortReversed);
}

From source file:com.androidaq.AndroiDAQMain.java

private void saveMyPreferences() {
    //Log.e(TAG, "Save Preferences Fired");
    Context context = getApplicationContext();
    Bundle myBundle = ((AndroiDAQAdapter) pager.getAdapter()).getUIStates();
    boolean[] isOutputCh = myBundle.getBooleanArray("isInput");
    boolean[] isDigCh = myBundle.getBooleanArray("isDig");
    boolean[] outputState = myBundle.getBooleanArray("outputState");
    String[] desiredFreq = myBundle.getStringArray("desiredFreqs");
    String[] desiredDuty = myBundle.getStringArray("desiredDutys");
    saveBooleanArray(isOutputCh, "isInput", context);
    saveBooleanArray(isDigCh, "isDig", context);
    saveBooleanArray(outputState, "outputState", context);
    saveStringArray(desiredFreq, "desiredFreqs", context);
    saveStringArray(desiredDuty, "desiredDutys", context);

    /*Example//from   www  .j av  a  2  s.  c  o m
    mEditor.putInt("setTime", countSecs);
    mEditor.putBoolean("timeSet", timeIsSet);
    mEditor.putString("project", project);
    mEditor.commit(); */
}

From source file:com.androidaq.AndroiDAQTCPMain.java

private void saveMyPreferences() {
    //Log.e(TAG, "Save Preferences Fired");
    Context context = getApplicationContext();
    Bundle myBundle = ((AndroiDAQTCPAdapter) pager.getAdapter()).getUIStates();
    boolean[] isOutputCh = myBundle.getBooleanArray("isInput");
    boolean[] isDigCh = myBundle.getBooleanArray("isDig");
    boolean[] outputState = myBundle.getBooleanArray("outputState");
    String[] desiredFreq = myBundle.getStringArray("desiredFreqs");
    String[] desiredDuty = myBundle.getStringArray("desiredDutys");
    saveBooleanArray(isOutputCh, "isInput", context);
    saveBooleanArray(isDigCh, "isDig", context);
    saveBooleanArray(outputState, "outputState", context);
    saveStringArray(desiredFreq, "desiredFreqs", context);
    saveStringArray(desiredDuty, "desiredDutys", context);

    /*Example/* w  ww  .  j a va  2s.co m*/
    mEditor.putInt("setTime", countSecs);
    mEditor.putBoolean("timeSet", timeIsSet);
    mEditor.putString("project", project);
    mEditor.commit(); */
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.DisplayStopDataFragment.java

/**
 * {@inheritDoc}/*from ww w. j  av a  2  s  .  c om*/
 */
@Override
public Loader<BusTimesResult> onCreateLoader(final int id, final Bundle args) {
    if (args == null)
        return null;

    showProgress();
    busTimesLoading = true;

    return new BusTimesLoader(getActivity(), new EdinburghParser(), args.getStringArray(LOADER_ARG_STOPCODES),
            args.getInt(LOADER_ARG_NUMBER_OF_DEPARTURES, 4));
}