List of usage examples for android.os Bundle getStringArray
@Nullable
public String[] getStringArray(@Nullable String key)
From source file:Main.java
static public String[] unpackStartExperimentPlugins(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null) return null; return extras.getStringArray("plugins"); }
From source file:com.vonglasow.michael.satstat.utils.PermissionHelper.java
/** * Requests permissions to be granted to this application. * /*w w w.j a va2 s . co m*/ * 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:com.google.android.apps.muzei.api.internal.SourceState.java
public static SourceState fromBundle(Bundle bundle) { SourceState state = new SourceState(); Bundle artworkBundle = bundle.getBundle("currentArtwork"); if (artworkBundle != null) { state.mCurrentArtwork = Artwork.fromBundle(artworkBundle); }//w ww. j av a2 s. c om state.mDescription = bundle.getString("description"); state.mWantsNetworkAvailable = bundle.getBoolean("wantsNetworkAvailable"); String[] commandsSerialized = bundle.getStringArray("userCommands"); if (commandsSerialized != null && commandsSerialized.length > 0) { for (String s : commandsSerialized) { state.mUserCommands.add(UserCommand.deserialize(s)); } } return state; }
From source file:dev.drsoran.moloko.util.UIUtils.java
public final static void inflateTags(Context context, ViewGroup container, Collection<String> tags, Bundle configuration) { if (configuration == null) { configuration = Bundle.EMPTY;/*from w w w . ja va 2 s . co m*/ } final int tagPos = getTaggedViewPos(container, "tag_name"); if (tagPos != -1) { container.removeViews(tagPos, container.getChildCount() - tagPos); } // inflate the stub and add tags if (tags.size() > 0 && !configuration.containsKey(REMOVE_ALL_TAGS)) { try { final String[] tagsToRemove = configuration.getStringArray(REMOVE_TAGS_EQUALS); for (String tagText : tags) { boolean remove = false; if (tagsToRemove != null) { for (int i = 0; i < tagsToRemove.length && !remove; i++) { remove = tagsToRemove[i].equalsIgnoreCase(tagText); } } if (!remove) { final TextView tagView = (TextView) View.inflate(context, R.layout.tag_button, null); tagView.setText(tagText); container.addView(tagView); } } } catch (Throwable e) { throw new InflateException(e); } } if (container.getChildCount() > 0) container.setVisibility(View.VISIBLE); else container.setVisibility(View.GONE); }
From source file:us.socialgoodworking.mocklocation.SelectRouteDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle b = this.getArguments(); routes = b.getStringArray("routes"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Select a Route"); if (bSwitchButtonPlacement) { // Really the positive, but reversed to be compatible with ICS and onward. builder.setCancelable(false)//ww w . j a va 2 s . c o m .setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { listener.onSelectRouteDialogNegativeClick(dialog); } }).setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { listener.onSelectRouteDialogPositiveClick(dialog, selectedRoute); } }); } else { builder.setCancelable(false) .setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { listener.onSelectRouteDialogNegativeClick(dialog); } }).setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { listener.onSelectRouteDialogPositiveClick(dialog, selectedRoute); } }); } builder.setSingleChoiceItems(routes, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { selectedRoute = routes[which]; } }); return builder.create(); }
From source file:monakhv.android.samlib.dialogs.SingleChoiceSelectDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); data = args.getStringArray(EXTRA_DATA); title = args.getString(EXTRA_TITLE); selected = args.getInt(EXTRA_SELECTED); }
From source file:com.android.inputmethod.latin.permissions.PermissionsActivity.java
@Override protected void onResume() { super.onResume(); // Only do request when there is no pending request to avoid duplicated requests. if (mPendingRequestCode == INVALID_REQUEST_CODE) { final Bundle extras = getIntent().getExtras(); final String[] permissionsToRequest = extras.getStringArray(EXTRA_PERMISSION_REQUESTED_PERMISSIONS); mPendingRequestCode = extras.getInt(EXTRA_PERMISSION_REQUEST_CODE); // Assuming that all supplied permissions are not granted yet, so that we don't need to // check them again. PermissionsUtil.requestPermissions(this, mPendingRequestCode, permissionsToRequest); }//from w ww .j a v a 2 s . com }
From source file:librerias.ActivityProgress_detalle.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override// ww w .ja va 2 s . co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("Detalle del Trmite"); int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); if (titleId == 0) titleId = com.actionbarsherlock.R.id.abs__action_bar_title; TextView custom = (TextView) findViewById(titleId); custom.setTypeface(CustomTypeFace.getInstance(this).getTypeFace()); Bundle bundle = getIntent().getExtras(); datos_tramite = bundle.getStringArray("datos_tramite"); //verifica si tienes coneccin a internet if (verifica_internet.checkConex(getApplicationContext())) { Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content); if (fragment == null) { fragment = Detalle_tramite.newInstance(); Bundle args = new Bundle(); args.putStringArray("datos_tramite", datos_tramite); fragment.setArguments(args); getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit(); } //getSupportActionBar().setTitle("Lista de Trmites"); } else { Toast.makeText(getApplicationContext(), "Verifique estar conectado a INTERNET", Toast.LENGTH_LONG) .show(); finish(); } }
From source file:com.phillips.phillipscs.MyGcmListenerService.java
/** * Called when message is received./*from w w w .jav a2s .c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { // String requestId = data.getString("request_id"); String[] message = data.getStringArray("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } if (message != null) { sendNotification(message[0], message[1]); } }
From source file:com.achep.base.ui.fragments.dialogs.PermissionsDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get permissions array Bundle args = getArguments(); assert args != null; String[] p = args.getStringArray(KEY_PERMISSIONS); mPermissions = new Permission[p.length]; for (int i = 0; i < p.length; i++) { final String name = p[i]; mPermissions[i] = Permission.newInstance(getActivity(), name); }//from w ww .ja v a 2 s . co m }