List of usage examples for android.content Intent putStringArrayListExtra
public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value)
From source file:ua.naiksoftware.rxgoogle.BaseRx.java
protected void requestPermissions(ArrayList<String> permissions, SubscriberWrapper subscriber) { List<String> missingPermissions = new ArrayList<>(permissions.size()); for (String permission : permissions) { if (ContextCompat.checkSelfPermission(ctx, permission) != PackageManager.PERMISSION_GRANTED) { missingPermissions.add(permission); }// w w w.j av a2s .c o m } int count = missingPermissions.size(); if (count > 0) { int requestCode = hashCode(); observablePermissionsHandlers.put(requestCode, new Pair<BaseRx, SubscriberWrapper>(BaseRx.this, subscriber)); Intent intent = new Intent(ctx, ResolutionActivity.class); intent.putExtra(ResolutionActivity.ARG_PERMISSIONS_REQUEST_CODE, requestCode); intent.putStringArrayListExtra(ResolutionActivity.ARG_PERMISSIONS_LIST, permissions); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(intent); } else { handlePermissionsResult(permissions, permissions, subscriber); } }
From source file:es.uma.lcc.tasks.PicturesViewTask.java
@Override public Void doInBackground(Void... args) { DefaultHttpClient httpclient = new DefaultHttpClient(); final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); httpclient.setParams(params);/*from w w w .j av a 2 s . co m*/ String target = SERVERURL + "?" + QUERYSTRING_ACTION + "=" + ACTION_MYPICTURES; HttpGet httpget = new HttpGet(target); while (mCookie == null) mCookie = mMainActivity.getCurrentCookie(); httpget.setHeader("Cookie", mCookie.getName() + "=" + mMainActivity.getCurrentCookie().getValue()); try { HttpResponse response = httpclient.execute(httpget); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { throw new IOException("Invalid response from server: " + status.toString()); } HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = entity.getContent(); ByteArrayOutputStream content = new ByteArrayOutputStream(); // Read response into a buffered stream int readBytes = 0; byte[] sBuffer = new byte[256]; while ((readBytes = inputStream.read(sBuffer)) != -1) { content.write(sBuffer, 0, readBytes); } String result = new String(content.toByteArray()); try { JSONArray jsonArray = new JSONArray(result); if (jsonArray.length() == 0) { // should never happen Log.e(APP_TAG, LOG_ERROR + ": Malformed response from server"); } else { // Elements in a JSONArray keep their order JSONObject successState = jsonArray.getJSONObject(0); if (successState.get(JSON_RESULT).equals(JSON_RESULT_ERROR)) { if (successState.getBoolean(JSON_ISAUTHERROR) && mIsFirstRun) { mIsAuthError = true; } else { Log.e(APP_TAG, LOG_ERROR + ": Server found an error: " + successState.get("reason")); } } else { ArrayList<String> pics = new ArrayList<String>(); ArrayList<String> ids = new ArrayList<String>(); ArrayList<String> dates = new ArrayList<String>(); SimpleDateFormat oldFormat = new SimpleDateFormat(MISC_DATE_FORMAT, Locale.US); SimpleDateFormat newFormat = (SimpleDateFormat) java.text.SimpleDateFormat .getDateTimeInstance(); JSONObject obj; for (int i = 1; i < jsonArray.length(); i++) { obj = jsonArray.getJSONObject(i); Date d = oldFormat.parse(obj.getString(JSON_DATECREATED)); dates.add(newFormat.format(d)); pics.add(obj.getString(JSON_FILENAME)); ids.add(obj.getString(JSON_PICTUREID)); } Intent intent = new Intent(mMainActivity, PicturesViewActivity.class); intent.putStringArrayListExtra("pictures", pics); intent.putStringArrayListExtra("ids", ids); intent.putStringArrayListExtra("dates", dates); mMainActivity.startActivityForResult(intent, ACTIVITY_VIEW_MY_PICTURES); } } } catch (JSONException jsonEx) { Log.e(APP_TAG, LOG_ERROR + ": Malformed JSON response from server"); } catch (ParseException e) { // Will not happen: dates are sent by the server in a correct format Log.e(APP_TAG, LOG_ERROR + ": Malformed date sent by server"); } } else { // entity is null Log.e(APP_TAG, LOG_ERROR + ": null response from server"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:es.uma.lcc.tasks.PictureDetailsTask.java
@Override public Void doInBackground(Void... args) { DefaultHttpClient httpclient = new DefaultHttpClient(); int width, height; final HttpParams params = new BasicHttpParams(); HttpClientParams.setRedirecting(params, false); httpclient.setParams(params);/*from w w w . j av a2s .co m*/ String target = SERVERURL + "?" + QUERYSTRING_ACTION + "=" + ACTION_PICTUREDETAILS + "&" + QUERYSTRING_PICTUREID + "=" + mPicId; HttpGet httpget = new HttpGet(target); while (mCookie == null) mCookie = mMainActivity.getCurrentCookie(); httpget.setHeader("Cookie", mCookie.getName() + "=" + mMainActivity.getCurrentCookie().getValue()); try { HttpResponse response = httpclient.execute(httpget); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { throw new IOException("Invalid response from server: " + status.toString()); } HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = entity.getContent(); ByteArrayOutputStream content = new ByteArrayOutputStream(); // Read response into a buffered stream int readBytes = 0; byte[] sBuffer = new byte[256]; while ((readBytes = inputStream.read(sBuffer)) != -1) { content.write(sBuffer, 0, readBytes); } String result = new String(content.toByteArray()); try { JSONArray jsonArray = new JSONArray(result); if (jsonArray.length() == 0) { // should never happen Log.e(APP_TAG, LOG_ERROR + ": Malformed response from server"); } else { // Elements in a JSONArray keep their order JSONObject successState = jsonArray.getJSONObject(0); if (successState.get(JSON_RESULT).equals(JSON_RESULT_ERROR)) { if (successState.getBoolean(JSON_ISAUTHERROR) && mIsFirstRun) { mIsAuthError = true; } else { Log.e(APP_TAG, LOG_ERROR + ": Server found an error: " + successState.get(JSON_REASON)); } } else { ArrayList<String> users = new ArrayList<String>(); ArrayList<String> coords = new ArrayList<String>(); ArrayList<String> ids = new ArrayList<String>(); JSONObject obj = jsonArray.getJSONObject(0); width = obj.getInt(JSON_IMGWIDTH); height = obj.getInt(JSON_IMGHEIGHT); for (int i = 1; i < jsonArray.length(); i++) { obj = jsonArray.getJSONObject(i); users.add(obj.getString(JSON_USERNAME)); coords.add(formatCoordinates(obj.getInt(JSON_HSTART), obj.getInt(JSON_HEND), obj.getInt(JSON_VSTART), obj.getInt(JSON_VEND))); ids.add(obj.getString(JSON_PERMISSIONID)); } Intent intent = new Intent(mMainActivity, PictureDetailsActivity.class); intent.putStringArrayListExtra("users", users); intent.putStringArrayListExtra("coordinates", coords); intent.putStringArrayListExtra("ids", ids); intent.putExtra("height", height); intent.putExtra("width", width); intent.putExtra("picId", mPicId); intent.putExtra("username", mMainActivity.getUserEmail()); mMainActivity.startActivityForResult(intent, ACTIVITY_PICTURE_DETAILS); } } } catch (JSONException jsonEx) { Log.e(APP_TAG, LOG_ERROR + ": Malformed JSON response from server"); } } else { // entity is null Log.e(APP_TAG, LOG_ERROR + ": null response from server"); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:org.alfresco.mobile.android.application.extension.scansnap.ScanSnapResultActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(android.R.layout.activity_list_item); String action = getIntent().getAction(); // Fujitsu ScanSnap Integration if ((Intent.ACTION_VIEW.equals(action)) && ScanSnapManager.getInstance(this) != null) { // Prepare the new Intent Intent i = new Intent(); i.setAction(PrivateIntent.ACTION_SCAN_RESULT); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Retrieve Information from the Intent if (getIntent().getStringArrayListExtra(ScanSnapManager.CARRY_FILE) != null) { i.putStringArrayListExtra(PrivateIntent.EXTRA_FILE_PATH, getIntent().getStringArrayListExtra(ScanSnapManager.CARRY_FILE)); }/*from w w w . j a v a 2 s .c o m*/ // end this activity. It's just a passthrough finish(); startActivity(i); } }
From source file:org.uis.luu.nav.ImageFragment.java
private void startPic(int position) { Intent it = new Intent(getActivity(), PicActivity.class); it.putExtra("position", position); it.putStringArrayListExtra("item", mAdapter.getData()); //it.putExtra("item",1); startActivity(it);// w w w . ja v a 2 s . co m }
From source file:com.yanzhenjie.durban.DurbanActivity.java
private void setResultSuccessful() { Intent intent = new Intent(); intent.putStringArrayListExtra(Durban.KEY_OUTPUT_IMAGE_LIST, mOutputPathList); setResult(RESULT_OK, intent);//from w w w . j a v a 2s .c o m finish(); }
From source file:com.yanzhenjie.durban.DurbanActivity.java
private void setResultFailure() { Intent intent = new Intent(); intent.putStringArrayListExtra(Durban.KEY_OUTPUT_IMAGE_LIST, mOutputPathList); setResult(RESULT_CANCELED, intent);/*w w w . j a v a 2s. c o m*/ finish(); }
From source file:com.nononsenseapps.filepicker.ui.core.AbstractFilePickerActivity.java
@Override public void onFilesPicked(final List<Uri> files) { Intent i = new Intent(); i.putExtra(Extras.EXTRA_ALLOW_MULTIPLE, true); ArrayList<String> paths = new ArrayList<String>(); for (Uri file : files) { paths.add(file.toString());// w ww. j a v a 2 s . c o m } i.putStringArrayListExtra(Extras.EXTRA_PATHS, paths); setResult(Activity.RESULT_OK, i); finish(); }
From source file:com.seregil13.literarytracker.lightnovel.LightNovelEditFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_light_novel_edit, container, false); this.mTitleET = (EditText) view.findViewById(R.id.title); this.mAuthorET = (EditText) view.findViewById(R.id.author); this.mDescriptionET = (EditText) view.findViewById(R.id.description); this.mTranslatorSiteET = (EditText) view.findViewById(R.id.translatorSite); this.mCompletedCB = (CheckBox) view.findViewById(R.id.completionStatus); Button editGenres = (Button) view.findViewById(R.id.genreSelection); Button cancel = (Button) view.findViewById(R.id.cancelButton); Button save = (Button) view.findViewById(R.id.saveButton); cancel.setOnClickListener(this.mCancelListener); save.setOnClickListener(this.mSaveListener); editGenres.setOnClickListener(new View.OnClickListener() { @Override/*from w ww . j ava 2s . co m*/ public void onClick(View v) { Intent intent = new Intent(getActivity().getApplicationContext(), GenreSelectionActivity.class); intent.putStringArrayListExtra(JsonKeys.GENRES.toString(), mGenres); startActivityForResult(intent, LiteraryTrackerUtils.GENRE_REQUEST_CODE); } }); mTitleET.setText(mTitle); mAuthorET.setText(mAuthor); mDescriptionET.setText(mDescription); mTranslatorSiteET.setText(mTranslatorSite); mCompletedCB.setChecked(Boolean.parseBoolean(mCompleted)); return view; }
From source file:net.xisberto.phonetodesktop.network.GoogleTasksService.java
private void handleActionList() throws UserRecoverableAuthIOException, IOException { List<Task> list = client.tasks().list(list_id).execute().getItems(); if (list != null) { ArrayList<String> ids = new ArrayList<String>(); ArrayList<String> titles = new ArrayList<String>(); for (Task task : list) { ids.add(task.getId());//from w ww .j ava2 s .com titles.add(task.getTitle()); } Intent broadcast = new Intent(Utils.ACTION_LIST_TASKS); broadcast.putStringArrayListExtra(Utils.EXTRA_IDS, ids); broadcast.putStringArrayListExtra(Utils.EXTRA_TITLES, titles); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); } }