List of usage examples for android.content Intent putStringArrayListExtra
public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value)
From source file:com.gizwits.smartlight.activity.MainListActivity.java
/** * Inits the events.//from w w w. ja va 2 s . c o m */ private void initEvents() { ivMenu.setOnClickListener(this); tvTitle.setOnClickListener(this); llFooter.setOnClickListener(this); tvEditSceneName.setOnClickListener(this); iftttButton.setOnClickListener(this); iftttButton.setClickable(false); // etGroup.setOnClickListener(this); //For lightness moveStep1 = (float) (((float) screenWidth / (float) 254) * 0.8); //For Hue moveStep2 = (float) (((float) screenWidth / (float) 65279) * 0.8); //For saturation moveStep3 = (float) (((float) screenWidth / (float) 254) * 0.8); lvDevice.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!mAdapter.getItem(position).isOnline()) return; if (mAdapter.getChoosedPos() == position) { mView.toggle(); return; } mAdapter.setChoosedPos(position); mXpgWifiDevice = bindlist.get(position); loginDevice(mXpgWifiDevice); } }); sbLightness.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbLightness.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbLightness.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbLightness.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mLightness = seekBar.getProgress(); text_light.layout((int) (mLightness * moveStep1), 20, screenWidth, 80); text_light.setText(Integer.toString(mLightness)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cLightnessGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cLightness(selectSubDevice, seekBar.getProgress()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); sbSaturation.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbSaturation.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbSaturation.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbSaturation.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mSaturation = seekBar.getProgress(); text_saturation.layout((int) (mSaturation * moveStep3), 20, screenWidth, 80); text_saturation.setText(Integer.toString(mSaturation)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cSaturationGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cSaturation(selectSubDevice, seekBar.getProgress()); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // TODO Auto-generated method stub } }); sbColor.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: sbColor.getParent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_CANCEL: sbColor.getParent().requestDisallowInterceptTouchEvent(false); break; } return false; } }); sbColor.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub mHue = seekBar.getProgress(); text_hue.layout((int) (mHue * moveStep2), 20, screenWidth, 80); text_hue.setText(Integer.toString(mHue)); if (!selectGroup.equals("") && selectGroup != null) { mCenter.cColorGroup(selectGroup, seekBar.getProgress()); } else { mCenter.cColor(selectSubDevice, seekBar.getProgress()); } } @Override public void onProgressChanged(SeekBar arg0, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar bar) { } }); alpha_bg.setOnClickListener(this); ivEdit.setOnClickListener(this); sclContent.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (position == list.size() - 1) { Intent intent = new Intent(MainListActivity.this, EditGroupActivity.class); intent.putStringArrayListExtra("ledList", GroupDevice.getAllName(ledList)); intent.putExtra("did", "" + centralControlDevice.getDid()); startActivity(intent); } } }); sclContent.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh(RefreshableListView listView) { // TODO Auto-generated method stub Log.i(TAG, "slip down to refresh........."); mCenter.cGetGroups(setmanager.getUid(), setmanager.getToken(), Configs.PRODUCT_KEY_Sub);//? mCenter.cGetSubDevicesList(centralControlDevice); final Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { // TODO Auto-generated method stub runOnUiThread(new Runnable() { public void run() { sclContent.completeRefreshing(); } }); timer.cancel(); } }, 2000); } }); btnSwitch.setOnClickListener(this); addSceneButton.setOnClickListener(this); sceneListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { Object o = sceneListView.getItemAtPosition(position); scene obj_itemDetails = (scene) o; Log.i(TAG, "click now is " + obj_itemDetails.getName() + " " + obj_itemDetails.getValue()); } }); }
From source file:me.tb.player.SkeletonActivity.java
public void setViewVisibility() { if (mAlertDialog != null) { mAlertDialog.dismiss();/*from w w w . ja v a 2s . c om*/ } if (isViewingBoardAfterTurn) { Intent intent = new Intent(SkeletonActivity.this, AfterTurnComplete.class); intent.putStringArrayListExtra("button_letter", (ArrayList) bl.getButton_letter()); intent.putStringArrayListExtra("list1", (ArrayList) lv1View); intent.putStringArrayListExtra("list2", (ArrayList) lv2View); intent.putExtra("score1", gp1.score.getText().toString()); intent.putExtra("score2", gp2.score.getText().toString()); intent.putExtra("name1", fullName1[0]); intent.putExtra("name2", fullName2[0]); intent.putExtra("pic1", playerPhotoUrl1); intent.putExtra("pic2", playerPhotoUrl2); intent.putExtra("tiles", Integer.toString(bl.getList_of_letters().size())); intent.putExtra("share", shareMessageCombo); if (secondPlayerRematch) { myParticipantId = getNextParticipantId(); } intent.putExtra("nextPlayerTurn", myParticipantId); startActivity(intent); SkeletonActivity.this.finish(); } }
From source file:ee.ioc.phon.android.speak.RecognizerIntentActivity.java
/** * Sets the RESULT_OK intent. Adds the recorded audio data if the caller has requested it * and the requested format is supported or unset. *//* w ww. j a v a 2 s .co m*/ private void setResultIntent(final Handler handler, ArrayList<String> matches) { Intent intent = new Intent(); if (mExtras.getBoolean(Extras.GET_AUDIO)) { String audioFormat = mExtras.getString(Extras.GET_AUDIO_FORMAT); if (audioFormat == null) { audioFormat = Constants.DEFAULT_AUDIO_FORMAT; } if (Constants.SUPPORTED_AUDIO_FORMATS.contains(audioFormat)) { try { FileOutputStream fos = openFileOutput(Constants.AUDIO_FILENAME, Context.MODE_PRIVATE); fos.write(mService.getCompleteRecordingAsWav()); fos.close(); Uri uri = Uri .parse("content://" + FileContentProvider.AUTHORITY + "/" + Constants.AUDIO_FILENAME); // TODO: not sure about the type (or if it's needed) intent.setDataAndType(uri, audioFormat); } catch (FileNotFoundException e) { Log.e(LOG_TAG, "FileNotFoundException: " + e.getMessage()); } catch (IOException e) { Log.e(LOG_TAG, "IOException: " + e.getMessage()); } } else { if (Log.DEBUG) { handler.sendMessage(createMessage(MSG_TOAST, String.format(getString(R.string.toastRequestedAudioFormatNotSupported), audioFormat))); } } } intent.putStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS, matches); setResult(Activity.RESULT_OK, intent); }
From source file:com.f8full.casserolesencours.CasserolesEnCoursActivity.java
public void onViewerModeClick(View view) { //TODO: View only my data on the map /*if(mViewOnMasterID == null) {/* w w w .j a va 2 s .c o m*/ toastMessage(getString(R.string.anonimizeRequired)); return; }*/ String timeFilter = ((Spinner) findViewById(R.id.timeFilterSpinner)).getSelectedItem().toString(); String distanceFilter = ((Spinner) findViewById(R.id.distanceFilterSpinner)).getSelectedItem().toString(); String whereClause = ""; if (distanceFilter.equals("--") == false) //time filtering requested by user { if (mAlohar.getPlaceManager().getCurrentLocation().getLatitude() == 0.0 || mAlohar.getPlaceManager().getCurrentLocation().getLongitude() == 0.0) { //Location not available toastMessage(getString(R.string.locationFilterError)); } else { String WhereClauseDistanceFilter = ""; switch (((Spinner) findViewById(R.id.distanceFilterSpinner)).getSelectedItemPosition()) { case 1: WhereClauseDistanceFilter = "100"; break; case 2: WhereClauseDistanceFilter = "300"; break; case 3: WhereClauseDistanceFilter = "500"; break; case 4: WhereClauseDistanceFilter = "1000"; break; case 5: WhereClauseDistanceFilter = "20000"; break; } //double testLat = 45.5334; //double testLong = -73.5838; //WHERE Pharmacy='yes' AND whereClause += "WHERE ST_INTERSECTS(Location, CIRCLE(LATLNG(" + Double.toString(mAlohar.getPlaceManager().getCurrentLocation().getLatitude()) //+ Double.toString(testLat) + "," + Double.toString(mAlohar.getPlaceManager().getCurrentLocation().getLongitude()) //+ Double.toString(testLong) + ")," + WhereClauseDistanceFilter + ")) "; //37.3242,-121.9806),5000))" } } if (timeFilter.equals("--") == false) //time filtering requested by user { if (whereClause.isEmpty() == false) { whereClause += "AND "; } else { whereClause += "WHERE "; } Calendar cl = Calendar.getInstance(); cl.setTime(new Date()); switch (((Spinner) findViewById(R.id.timeFilterSpinner)).getSelectedItemPosition()) { case 1: cl.add(Calendar.MINUTE, -5); break; case 2: cl.add(Calendar.MINUTE, -15); break; case 3: cl.add(Calendar.MINUTE, -45); break; case 4: cl.add(Calendar.HOUR, -2); break; } whereClause += "Date>='" + DateFormat.getDateTimeInstance().format(cl.getTime()) + "' "; } //1cmlx9aChHUYTWwYivaZucr7NHNsP_ulvEPX1FoM is master table public view ID String fromTableID = "1cmlx9aChHUYTWwYivaZucr7NHNsP_ulvEPX1FoM"; if (((CheckBox) findViewById(R.id.myDataCheckbox)).isChecked()) { fromTableID = mViewOnMasterID; } //excellent, just do a request to grab the locations and pass them around final String SqlQuery = "SELECT Date, Location, Description FROM " + fromTableID + " " + whereClause + "ORDER BY Date DESC LIMIT " + ((EditText) findViewById(R.id.nbIconsMax)).getText(); final boolean myLocationEnabled = !(((CheckBox) findViewById(R.id.worldMapChkBx)).isChecked()); final boolean timeColored = ((CheckBox) findViewById(R.id.timeColoredCheckbox)).isChecked(); new Thread((new Runnable() { public void run() { try { String encodedQuery = URLEncoder.encode(SqlQuery, "UTF-8"); GoogleUrl GUrl = new GoogleUrl(SERVICE_URL + "?sql=" + encodedQuery + "&encid=true"); HttpRequest request = mGOOGClient.getRequestFactory().buildGetRequest(GUrl); HttpHeaders headers = new HttpHeaders(); headers.setContentLength("0");//Required so that Fusion Table API considers request request.setHeaders(headers); HttpResponse response = request.execute(); if (response.getStatusCode() == 200) { //Here I have my data InputStreamReader inputStreamReader = new InputStreamReader(response.getContent()); BufferedReader bufferedStreamReader = new BufferedReader(inputStreamReader); CSVReader reader = new CSVReader(bufferedStreamReader); // The first line is the column names, and the remaining lines are the rows. List<String[]> csvLines = reader.readAll(); List<String> columns = Arrays.asList(csvLines.get(0)); List<String[]> rows = csvLines.subList(1, csvLines.size()); if (rows.size() == 0) { toastMessage("Table vide !"); return; } ArrayList<String> rowData = new ArrayList<String>(); for (String[] row : rows) { String toAdd = ""; for (String cell : row) { //No , in data, or things are gonna go horribly wrong here toAdd += cell + "|"; } //I have this last pesky separator ,it will give me an empty String on the other side rowData.add(toAdd); } Intent mapIntent = new Intent(getApplicationContext(), CasserolesEnCoursViewerActivity.class); mapIntent.putStringArrayListExtra("rowsData", rowData); mapIntent.putExtra("timeColored", timeColored); mapIntent.putExtra("myLocation", myLocationEnabled); if (myLocationEnabled) toastMessage(getString(R.string.lastContributionTapHintLocal)); else toastMessage(getString(R.string.lastContributionTapHintWorld)); //mapIntent.putExtra("relativeTime", ((CheckBox)findViewById(R.id.relativeTimeCheckbox)).isChecked()); startActivity(mapIntent); } } catch (HttpResponseException e) { if (e.getStatusCode() == 401) { mGOOGCredential.setAccessToken(null); SharedPreferences.Editor editor2 = mPrefs.edit(); editor2.remove(PREF_REFRESH_TOKEN); editor2.commit(); toastMessage("OAuth login required, redirecting..."); //This last Constant is weird startActivityForResult( new Intent().setClass(getApplicationContext(), OAuth2AccessTokenActivity.class), REQUEST_OAUTH2_AUTHENTICATE); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } })).start(); }
From source file:com.brandroidtools.filemanager.activities.NavigationActivity.java
/** * Method that verifies the intent passed to the activity, and checks * if a request is made like Search.// w w w .j av a2s. c o m * * @param intent The intent to check * @hide */ void checkIntent(Intent intent) { //Search action if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Intent searchIntent = new Intent(this, SearchActivity.class); searchIntent.setAction(Intent.ACTION_SEARCH); //- SearchActivity.EXTRA_SEARCH_DIRECTORY searchIntent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, getCurrentNavigationFragment().getCurrentDir()); //- SearchManager.APP_DATA if (intent.getBundleExtra(SearchManager.APP_DATA) != null) { Bundle bundle = new Bundle(); bundle.putAll(intent.getBundleExtra(SearchManager.APP_DATA)); searchIntent.putExtra(SearchManager.APP_DATA, bundle); } //-- SearchManager.QUERY String query = intent.getStringExtra(SearchManager.QUERY); if (query != null) { searchIntent.putExtra(SearchManager.QUERY, query); } //- android.speech.RecognizerIntent.EXTRA_RESULTS ArrayList<String> extraResults = intent .getStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS); if (extraResults != null) { searchIntent.putStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS, extraResults); } startActivityForResult(searchIntent, INTENT_REQUEST_SEARCH); return; } // Navigate to the requested path String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO); if (navigateTo != null && navigateTo.length() >= 0) { getCurrentNavigationFragment().changeCurrentDir(navigateTo); } }
From source file:com.ifoer.expeditionphone.MainActivity.java
public void loadSo(String dataDirs, String sdPath) { String paths = dataDir + "/libs/" + dataDirs; String sdPaths = Constant.LOCAL_SERIALNO_PATH + dataDirs; if (Copy_File.copy(sdPaths, paths) == 0) { Copy_File.list = new ArrayList(); Copy_File.findAllSoFile(paths); if (Copy_File.list.size() > 0) { Intent menu = new Intent(this, CarDiagnoseActivity.class); menu.putStringArrayListExtra("FileList", Copy_File.list); menu.putExtra("paths", new StringBuilder(String.valueOf(sdPaths)).append(sdPath).toString()); menu.setFlags(AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED); SimpleDialog.closeProgressDialog(this.progressDialog); startActivity(menu);// ww w . j a v a 2s .c om overridePendingTransition(0, 0); } } }
From source file:org.uguess.android.sysinfo.ProcessManager.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Activity ctx = getActivity();/*from w w w .java2 s . c o m*/ if (item.getItemId() == MI_PREFERENCE) { Intent it = new Intent(ctx, ProcessSettings.class); it.putExtra(PREF_KEY_REFRESH_INTERVAL, Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_REFRESH_INTERVAL, REFRESH_LOW)); it.putExtra(PREF_KEY_SORT_ORDER_TYPE, Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SORT_ORDER_TYPE, ORDER_TYPE_NAME)); it.putExtra(PREF_KEY_SORT_DIRECTION, Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SORT_DIRECTION, ORDER_ASC)); it.putExtra(PREF_KEY_IGNORE_ACTION, Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_IGNORE_ACTION, IGNORE_ACTION_HIDDEN)); it.putExtra(PREF_KEY_DEFAULT_TAP_ACTION, Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_DEFAULT_TAP_ACTION, ACTION_MENU)); it.putStringArrayListExtra(PREF_KEY_IGNORE_LIST, getIgnoreList(ctx.getSharedPreferences(PSTORE_PROCESSMANAGER, Context.MODE_PRIVATE))); it.putExtra(PREF_KEY_SHOW_MEM, Util.getBooleanOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_MEM)); it.putExtra(PREF_KEY_SHOW_CPU, Util.getBooleanOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_CPU)); it.putExtra(PREF_KEY_SHOW_SYS_PROC, Util.getBooleanOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_SYS_PROC)); it.putExtra(PREF_KEY_SHOW_KILL_WARN, Util.getBooleanOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_SHOW_KILL_WARN)); startActivityForResult(it, 1); return true; } return false; }
From source file:com.support.android.designlibdemo.activities.CampaignDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); imageUrls = new ArrayList<String>(); customProgress = (CustomProgress) findViewById(R.id.pbGoal); ivCampaignImage = (ImageView) findViewById(R.id.ivCampaighnImage); tvCampaignOverview = (TextView) findViewById(R.id.tvCampaignOverview); ivArrowDown = (ImageView) findViewById(R.id.ivArrowDown); // tvCampaignText = (TextView) findViewById(R.id.tvCampaignDetails); tvGoal = (TextView) findViewById(R.id.tvCampaignGoal); btTakeActionRipple = (RippleView) findViewById(R.id.bt_take_an_action_ripple); campaign = (Campaign) getIntent().getSerializableExtra(ITENT_TAG); if (campaign.getIsSupported()) { btTakeActionRipple.setVisibility(View.GONE); ivArrowDown.setImageResource(R.drawable.ic_checked); } else {//w w w. j a v a2 s . c o m btTakeActionRipple.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() { @Override public void onComplete(RippleView rippleView) { Intent i = new Intent(CampaignDetailActivity.this, SignPetitionActivity.class); i.putExtra(ITENT_TAG, campaign); startActivity(i); } }); } getImagesUploadedByUserForCampaign(campaign.getObjectId()); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(false); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(campaign.getTitle()); collapsingToolbar.getCollapsedTitleGravity(); loadBackdrop(campaign.getImageUrl(), ivCampaignImage); PrettyText goal = new PrettyText(); String decimalGoal = ""; String decimalCount = ""; //setting up progress bar customProgress.setProgressColor(getResources().getColor(R.color.green_500)); customProgress.setProgressBackgroundColor(getResources().getColor(R.color.green_200)); customProgress.setMaximumPercentage(calculatePercentage(campaign.getGoal(), campaign.getGoalCount())); customProgress.useRoundedRectangleShape(30.0f); customProgress.setShowingPercentage(true); //set text above progress tvCampaignOverview.setText(campaign.getShortDescription()); expandableTextView = (ExpandableTextView) findViewById(R.id.viewmore); expandableTextView.setText(campaign.getLongDescription()); // tvCampaignText.setText(campaign.getLongDescription()); //set goal text decimalGoal = goal.addComma(campaign.getGoal()) + " signatures"; decimalCount = goal.addComma(campaign.getGoalCount()); tvGoal.setText(decimalCount + " out of " + decimalGoal); ivCampaignImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (imageUrls.size() > 0) { Intent i = new Intent(CampaignDetailActivity.this, PhotoGalleryActivity.class); i.putExtra(ITENT_TAG, campaign.getObjectId()); i.putStringArrayListExtra(ITENT_TAG, imageUrls); startActivity(i); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } else { buildDialogNoPictures(CampaignDetailActivity.this).show(); } } }); //set floating action button floatingCamera = (FloatingActionButton) findViewById(R.id.bt_camera); final int[] selection = new int[1]; floatingCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); final CameraDialog dialog = CameraDialog.newInstance("Add a new picture:"); dialog.setOnChoiceClickListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { selection[0] = which; } }); dialog.setPositiveListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (selection[0] == 0) { // create Intent to take a picture and return control to the calling application Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); photoUri = Uri.fromFile(getOutputMediaFile()); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); // set the image file name // Start the image capture intent to take photo startActivityForResult(intent, TAKE_PHOTO_CODE); } else { // Take the user to the gallery app to pick a photo Intent photoGalleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(photoGalleryIntent, PICK_PHOTO_CODE); } dialog.dismiss(); } }); dialog.setCancelClickListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(fm, "TAG_DIALOG"); } }); }
From source file:csms19.inapp.msg.customgallery.ImageFragment.java
private void setAdapter(Cursor imagecursor) { if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); mGalleryModelList.add(galleryModel); }// w w w. j a v a 2 s . c o m mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), "no media file available", Toast.LENGTH_SHORT).show(); } mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "image/*"); startActivity(intent); return true; } }); mImageGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText( getActivity(), "File size greater then" + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + "mb", Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText( getActivity(), "Max selected file " + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + "file", Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText( getActivity(), "Max selected file " + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + "file", Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:org.de.jmg.learn.MainActivity.java
public Intent getFileChooserIntent(boolean blnUniCode) { Intent intent = new Intent(this, FileChooser.class); ArrayList<String> extensions = new ArrayList<>(); extensions.add(".k??"); extensions.add(".v??"); extensions.add(".K??"); extensions.add(".V??"); extensions.add(".KAR"); extensions.add(".VOK"); extensions.add(".kar"); extensions.add(".vok"); extensions.add(".dic"); extensions.add(".DIC"); intent.putStringArrayListExtra("filterFileExtension", extensions); intent.putExtra("blnUniCode", blnUniCode); intent.putExtra("DefaultDir", (JMGDataDirectory != null && new File(JMGDataDirectory).exists()) ? JMGDataDirectory : Environment.getExternalStorageDirectory().getPath()); if (_blnUniCode) _oldUniCode = yesnoundefined.yes; else//from w w w. j ava2s . c om _oldUniCode = yesnoundefined.no; _blnUniCode = blnUniCode; return intent; }