Example usage for android.os Bundle getIntArray

List of usage examples for android.os Bundle getIntArray

Introduction

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

Prototype

@Nullable
public int[] getIntArray(@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:Main.java

public static void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    isShowing = savedInstanceState.getBoolean("isShowing");
    menuItems = savedInstanceState.getIntArray("drawables");
}

From source file:com.vonglasow.michael.satstat.utils.PermissionHelper.java

/**
 * Requests permissions to be granted to this application.
 * //from   w  w  w . j  a  v a2  s. c  om
 * This method is a wrapper around
 * {@link android.support.v4.app.ActivityCompat#requestPermissions(android.app.Activity, String[], int)}
 * which works in a similar way, except it can be called from non-activity contexts. When called, it
 * displays a notification with a customizable title and text. When the user taps the notification, an
 * activity is launched in which the user is prompted to allow or deny the request.
 * 
 * After the user has made a choice,
 * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])}
 * is called, reporting whether the permissions were granted or not.
 * 
 * @param context The context from which the request was made. The context supplied must implement
 * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback} and will receive the
 * result of the operation.
 * @param permissions The requested permissions
 * @param requestCode Application specific request code to match with a result reported to
 * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])}
 * @param notificationTitle The title for the notification
 * @param notificationText The text for the notification
 * @param notificationIcon Resource identifier for the notification icon
 */
public static <T extends Context & OnRequestPermissionsResultCallback> void requestPermissions(final T context,
        String[] permissions, int requestCode, String notificationTitle, String notificationText,
        int notificationIcon) {
    ResultReceiver resultReceiver = new ResultReceiver(new Handler(Looper.getMainLooper())) {
        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            String[] outPermissions = resultData.getStringArray(Const.KEY_PERMISSIONS);
            int[] grantResults = resultData.getIntArray(Const.KEY_GRANT_RESULTS);
            context.onRequestPermissionsResult(resultCode, outPermissions, grantResults);
        }
    };

    Intent permIntent = new Intent(context, PermissionRequestActivity.class);
    permIntent.putExtra(Const.KEY_RESULT_RECEIVER, resultReceiver);
    permIntent.putExtra(Const.KEY_PERMISSIONS, permissions);
    permIntent.putExtra(Const.KEY_REQUEST_CODE, requestCode);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addNextIntent(permIntent);

    PendingIntent permPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setSmallIcon(notificationIcon)
            .setContentTitle(notificationTitle).setContentText(notificationText).setOngoing(true)
            //.setCategory(Notification.CATEGORY_STATUS)
            .setAutoCancel(true).setWhen(0).setContentIntent(permPendingIntent).setStyle(null);

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(requestCode, builder.build());
}

From source file:org.chromium.chrome.browser.util.IntentUtils.java

/**
 * Just like {@link Bundle#getIntArray(String)} but doesn't throw exceptions.
 *///from ww  w.j a v a 2  s .com
public static int[] safeGetIntArray(Bundle bundle, String name) {
    try {
        return bundle.getIntArray(name);
    } catch (Throwable t) {
        // Catches un-parceling exceptions.
        Log.e(TAG, "getIntArray failed on bundle " + bundle);
        return null;
    }
}

From source file:de.domjos.schooltools.helper.Helper.java

public static void receiveBroadCast(Context context, Intent intent, int id) {
    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        if (intent.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS)) {
            int[] ids = bundle.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS);
            AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
            appWidgetManager.notifyAppWidgetViewDataChanged(ids, id);
        }//from   ww w.j  av a 2s.  c o m
    }
}

From source file:org.akop.crosswords.fragment.BaseFragment.java

protected void readSparseBooleanArray(Bundle bundle, String prefix, SparseBooleanArray array) {
    int keys[] = bundle.getIntArray(prefix + "_keys");
    boolean values[] = bundle.getBooleanArray(prefix + "_values");

    if (keys != null && values != null) {
        for (int i = 0, n = keys.length; i < n; i++) {
            array.put(keys[i], values[i]);
        }/*from  w  w w .ja  v  a  2  s.  c om*/
    }
}

From source file:eu.geopaparazzi.library.core.dialogs.ZoomlevelDialogFragment.java

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

    Bundle arguments = getArguments();
    if (arguments != null) {
        int[] mInitialZoomlevelsObject = arguments.getIntArray(PREFS_KEY_ZOOMLEVELPROPERTIES);
        if (mInitialZoomlevelsObject != null) {
            mMinMaxZoomlevels = mInitialZoomlevelsObject;
        }//from  w  ww.ja  va 2  s .co m
    }
}

From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle args = getActivity().getIntent().getExtras();
    cameraIds = args.getIntArray("cameraIds");
    cameraUrls = args.getStringArray("cameraUrls");

    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_with_spinner, null);

    mRecyclerView = (RecyclerView) root.findViewById(R.id.my_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new CameraGroupImageAdapter(getActivity(), null);

    mRecyclerView.setAdapter(mAdapter);//from w ww. j  a v  a  2  s  .com

    mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getActivity()));

    // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are
    // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity.
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    mLoadingSpinner = root.findViewById(R.id.loading_spinner);
    mEmptyView = root.findViewById(R.id.empty_list_view);

    return root;
}

From source file:com.philliphsu.bottomsheetpickers.time.numberpad.NumberPadTimePickerDialog.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mInputtedDigits = savedInstanceState.getIntArray(KEY_DIGITS_INPUTTED);
        mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
        mAmPmState = savedInstanceState.getInt(KEY_AMPM_STATE);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeSetAtRuntime = savedInstanceState.getBoolean(KEY_THEME_SET_AT_RUNTIME);
    }/*from w  w  w.  ja va2 s  . c o m*/
}

From source file:us.parshall.ezandroid.activity.EZActivity.java

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

    int[] tmpPromptDialogList = savedInstanceState.getIntArray("promptDialogList");
    if (tmpPromptDialogList != null) {
        Log.i("EZActivity", String.format("Number of pending dialogs %d", tmpPromptDialogList.length));
        for (int i : tmpPromptDialogList) {
            this.promptDialogList.push(i);
        }//from  w  w w  . j  a  va2 s.c  o  m
    } else {
        Log.i("EZActivity", "tmpPromptDialogList is null");
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.EditorSectionManager.java

public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        // Store fragment saved states.
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);/*from  w  ww  . j av  a 2  s  . co  m*/
        Parcelable[] fragmentSavedStates = bundle.getParcelableArray("states");
        int[] stateKeys = bundle.getIntArray("state_keys");
        mSavedState.clear();
        if (fragmentSavedStates != null) {
            for (int i = 0; i < fragmentSavedStates.length; i++) {
                mSavedState.put(stateKeys[i], (Fragment.SavedState) fragmentSavedStates[i]);
            }
        }

        mCurrentPosition = bundle.getInt("current_position");
    }
}