List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** Handle "share" title-bar action. */ public void onShareClick(View v) { // TODO: consider bringing in shortlink to session final String shareString = getString(R.string.share_template, mTitleString, mHashtag); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, shareString); startActivity(Intent.createChooser(intent, getText(R.string.title_share))); }
From source file:com.albedinsky.android.support.intent.ContentIntent.java
/** */ @Override protected boolean onStart(@NonNull Intent intent) { startActivity(Intent.createChooser(intent, mDialogTitle)); return true; }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
public void shareComicLink() { Intent intent = new Intent(Intent.ACTION_SEND, null); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getCurrentComicUrl()); startActivity(Intent.createChooser(intent, "Share Link...")); }
From source file:com.fa.imaged.activity.DetailActivityV2.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.detail_like: if (detailImageLoaderv2.user_has_liked) { HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0); liker.execute();// w ww. jav a2s .c om try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } else { animatePhotoLike(); HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0); liker.execute(); try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } break; case R.id.detail_likeCounts: Intent i = new Intent(getBaseContext(), LikersActivity.class); i.putExtra("media_id", detailImageLoaderv2.id); i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")"); startActivity(i); break; case R.id.detail_share: Intent shareIntent = new Intent(); Uri uri = null; // Create share intent as described above if (!detailImageLoaderv2.video) { Drawable mDrawable = detailImageV2.getDrawable(); Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap(); String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name, detailImageLoaderv2.caption); uri = Uri.parse(path); } else { } shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, detailImageLoaderv2.caption + getResources().getString(R.string.share_postby) + detailImageLoaderv2.username); startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.share_to))); break; case R.id.detail_user_pic: viewProfile(this, detailImageLoaderv2); } }
From source file:gr.scify.newsum.ui.ViewActivity.java
private void Sendmail() { TextView title = (TextView) findViewById(R.id.title); String emailSubject = title.getText().toString(); // track the Send mail action if (getAnalyticsPref()) { EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Send Mail", emailSubject, 0l); }/*from w w w . ja va2s .c o m*/ final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/html"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "NewSum app : " + emailSubject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(sText)); startActivity(Intent.createChooser(emailIntent, "Email:")); }
From source file:com.kd.filmstrip.DetailActivityV2.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.detail_like: if (detailImageLoaderv2.user_has_liked) { HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0); liker.execute();/*from w w w . j a v a 2 s .co m*/ try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } else { animatePhotoLike(); HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0); liker.execute(); try { detailImageLoaderv2 = liker.get(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (detailImageLoaderv2.user_has_liked) { Drawable myIcon = getResources().getDrawable(R.drawable.ic_like); myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); detailLikeStatus.setImageDrawable(myIcon); } detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count)); } break; case R.id.detail_likeCounts: Intent i = new Intent(getBaseContext(), LikersActivity.class); i.putExtra("media_id", detailImageLoaderv2.id); i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")"); startActivity(i); break; case R.id.detail_share: Intent shareIntent = new Intent(); Uri uri = null; // Create share intent as described above if (!detailImageLoaderv2.video) { Drawable mDrawable = detailImageV2.getDrawable(); Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap(); String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name, detailImageLoaderv2.caption); uri = Uri.parse(path); } else { } shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, detailImageLoaderv2.caption + " Posted by @" + detailImageLoaderv2.username); startActivity(Intent.createChooser(shareIntent, "Share To")); break; case R.id.detail_user_pic: viewProfile(this, detailImageLoaderv2); } }
From source file:com.balakrish.gpstracker.WaypointsListActivity.java
/** * Handle activity menu//from w w w . j a v a 2 s . c om */ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); final long waypointId = waypointsArrayAdapter.getItem((int) info.id).getId(); Cursor tmpCursor; String sql; switch (item.getItemId()) { case 0: // update waypoint in db updateWaypoint(waypointId); return true; case 1: deleteWaypoint(waypointId); return true; case 2: // email waypoint data using default email client String elevationUnit = app.getPreferences().getString("elevation_units", "m"); String elevationUnitLocalized = Utils.getLocalizedElevationUnit(this, elevationUnit); sql = "SELECT * FROM waypoints WHERE _id=" + waypointId + ";"; tmpCursor = app.getDatabase().rawQuery(sql, null); tmpCursor.moveToFirst(); double lat1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lat")) / 1E6; double lng1 = tmpCursor.getDouble(tmpCursor.getColumnIndex("lng")) / 1E6; String messageBody = getString(R.string.title) + ": " + tmpCursor.getString(tmpCursor.getColumnIndex("title")) + "\n\n" + getString(R.string.lat) + ": " + Utils.formatLat(lat1, 0) + "\n" + getString(R.string.lng) + ": " + Utils.formatLng(lng1, 0) + "\n" + getString(R.string.elevation) + ": " + Utils.formatElevation(tmpCursor.getFloat(tmpCursor.getColumnIndex("elevation")), elevationUnit) + elevationUnitLocalized + "\n\n" + "http://maps.google.com/?ll=" + lat1 + "," + lng1 + "&z=10"; tmpCursor.close(); final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject_waypoint)); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, messageBody); this.startActivity(Intent.createChooser(emailIntent, getString(R.string.sending_email))); return true; case 3: this.showOnMap(waypointId); return true; case 4: // TODO: use a thread for online sync // sync one waypoint data with remote server // create temp waypoint from current record Waypoint wp = Waypoints.get(app.getDatabase(), waypointId); try { // preparing query string for calling web service String lat = Location.convert(wp.getLocation().getLatitude(), 0); String lng = Location.convert(wp.getLocation().getLongitude(), 0); String title = URLEncoder.encode(wp.getTitle()); String userName = app.getPreferences().getString("user_name", ""); String userPassword = app.getPreferences().getString("user_password", ""); String sessionValue = userName + "@" + Utils.md5("aripuca_session" + userPassword); if (userName.equals("") || userPassword.equals("")) { Toast.makeText(WaypointsListActivity.this, R.string.username_or_password_required, Toast.LENGTH_SHORT).show(); return false; } String queryString = "?do=ajax_map_handler&aripuca_session=" + sessionValue + "&action=add_point&lat=" + lat + "&lng=" + lng + "&z=16&n=" + title + "&d=AndroidSync"; // http connection HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet( app.getPreferences().getString("online_sync_url", "http://tracker.aripuca.com") + queryString); HttpResponse response = httpClient.execute(httpGet, localContext); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); response.getEntity().writeTo(outstream); // parsing JSON return JSONObject jsonObject = new JSONObject(outstream.toString()); Toast.makeText(WaypointsListActivity.this, jsonObject.getString("message").toString(), Toast.LENGTH_SHORT).show(); } catch (ClientProtocolException e) { Toast.makeText(WaypointsListActivity.this, "ClientProtocolException: " + e.getMessage(), Toast.LENGTH_SHORT).show(); } catch (IOException e) { Toast.makeText(WaypointsListActivity.this, "IOException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } catch (JSONException e) { Toast.makeText(WaypointsListActivity.this, "JSONException " + e.getMessage(), Toast.LENGTH_SHORT) .show(); } return true; default: return super.onContextItemSelected(item); } }
From source file:com.farmerbb.notepad.fragment.NoteViewFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Override default Android "up" behavior to instead mimic the back button getActivity().onBackPressed();/* w ww . j av a 2s.c o m*/ return true; // Edit button case R.id.action_edit: Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return true; // Delete button case R.id.action_delete: listener.showDeleteDialog(); return true; // Share menu item case R.id.action_share: // Send a share intent Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, contentsOnLoad); intent.setType("text/plain"); // Verify that the intent will resolve to an activity, and send if (intent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(Intent.createChooser(intent, getResources().getText(R.string.send_to))); return true; // Export menu item case R.id.action_export: listener.exportNote(filename); return true; // Print menu item case R.id.action_print: listener.printNote(contentsOnLoad); return true; default: return super.onOptionsItemSelected(item); } }
From source file:net.bluecarrot.lite.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setup the sharedPreferences savedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // if the app is being launched for the first time if (savedPreferences.getBoolean("first_run", true)) { //todo presentation // save the fact that the app has been started at least once savedPreferences.edit().putBoolean("first_run", false).apply(); }/*from w w w.j a va 2s . com*/ setContentView(R.layout.activity_main);//load the layout //**MOBFOX***// banner = (Banner) findViewById(R.id.banner); final Activity self = this; banner.setListener(new BannerListener() { @Override public void onBannerError(View view, Exception e) { //Toast.makeText(self, e.getMessage(), Toast.LENGTH_SHORT).show(); } @Override public void onBannerLoaded(View view) { //Toast.makeText(self, "banner loaded", Toast.LENGTH_SHORT).show(); } @Override public void onBannerClosed(View view) { //Toast.makeText(self, "banner closed", Toast.LENGTH_SHORT).show(); } @Override public void onBannerFinished(View view) { // Toast.makeText(self, "banner finished", Toast.LENGTH_SHORT).show(); } @Override public void onBannerClicked(View view) { //Toast.makeText(self, "banner clicked", Toast.LENGTH_SHORT).show(); } @Override public boolean onCustomEvent(JSONArray jsonArray) { return false; } }); banner.setInventoryHash(appHash); banner.load(); // setup the refresh layout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); swipeRefreshLayout.setColorSchemeResources(R.color.officialBlueFacebook, R.color.darkBlueSlimFacebookTheme);// set the colors swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refreshPage();//reload the page swipeRefresh = true; } }); /** get a subject and text and check if this is a link trying to be shared */ String sharedSubject = getIntent().getStringExtra(Intent.EXTRA_SUBJECT); String sharedUrl = getIntent().getStringExtra(Intent.EXTRA_TEXT); // if we have a valid URL that was shared by us, open the sharer if (sharedUrl != null) { if (!sharedUrl.equals("")) { // check if the URL being shared is a proper web URL if (!sharedUrl.startsWith("http://") || !sharedUrl.startsWith("https://")) { // if it's not, let's see if it includes an URL in it (prefixed with a message) int startUrlIndex = sharedUrl.indexOf("http:"); if (startUrlIndex > 0) { // seems like it's prefixed with a message, let's trim the start and get the URL only sharedUrl = sharedUrl.substring(startUrlIndex); } } // final step, set the proper Sharer... urlSharer = String.format("https://m.facebook.com/sharer.php?u=%s&t=%s", sharedUrl, sharedSubject); // ... and parse it just in case urlSharer = Uri.parse(urlSharer).toString(); isSharer = true; } } // setup the webView webViewFacebook = (WebView) findViewById(R.id.webView); setUpWebViewDefaults(webViewFacebook); //fits images to screen if (isSharer) {//if is a share request webViewFacebook.loadUrl(urlSharer);//load the sharer url isSharer = false; } else goHome();//load homepage // webViewFacebook.setOnTouchListener(new OnSwipeTouchListener(getApplicationContext()) { // public void onSwipeLeft() { // webViewFacebook.loadUrl("javascript:try{document.querySelector('#messages_jewel > a').click();}catch(e){window.location.href='" + // getString(R.string.urlFacebookMobile) + "messages/';}"); // } // // }); //WebViewClient that is the client callback. webViewFacebook.setWebViewClient(new WebViewClient() {//advanced set up // when there isn't a connetion public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { String summary = "<h1 style='text-align:center; padding-top:15%; font-size:70px;'>" + getString(R.string.titleNoConnection) + "</h1> <h3 " + "style='text-align:center; padding-top:1%; font-style: italic;font-size:50px;'>" + getString(R.string.descriptionNoConnection) + "</h3> <h5 style='font-size:30px; text-align:center; padding-top:80%; " + "opacity: 0.3;'>" + getString(R.string.awards) + "</h5>"; webViewFacebook.loadData(summary, "text/html; charset=utf-8", "utf-8");//load a custom html page noConnectionError = true; swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing } // when I click in a external link public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url == null || Uri.parse(url).getHost().endsWith("facebook.com") || Uri.parse(url).getHost().endsWith("m.facebook.com") || url.contains(".gif")) { //url is ok return false; } else { if (Uri.parse(url).getHost().endsWith("fbcdn.net")) { //TODO add the possibility to download and share directly Toast.makeText(getApplicationContext(), getString(R.string.downloadOrShareWithBrowser), Toast.LENGTH_LONG).show(); //TODO get bitmap from url Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } //if the link doesn't contain 'facebook.com', open it using the browser startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } //https://www.facebook.com/dialog/return/close?#_=_ } //START management of loading @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { //TODO when I push on messages, open messanger // if(url!=null){ // if (url.contains("soft=messages") || url.contains("facebook.com/messages")) { // Toast.makeText(getApplicationContext(),"Open Messanger", // Toast.LENGTH_SHORT).show(); // startActivity(new Intent(getPackageManager().getLaunchIntentForPackage("com.facebook.orca")));//messanger // } // } // show you progress image if (!swipeRefresh) { if (optionsMenu != null) {//TODO fix this. Sometimes it is null and I don't know why final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(R.layout.circular_progress_bar); } } swipeRefresh = false; super.onPageStarted(view, url, favicon); } @Override public void onPageFinished(WebView view, String url) { if (optionsMenu != null) {//TODO fix this. Sometimes it is null and I don't know why final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(null); } //load the css customizations String css = ""; if (savedPreferences.getBoolean("pref_blackTheme", false)) { css += getString(R.string.blackCss); } if (savedPreferences.getBoolean("pref_fixedBar", true)) { css += getString(R.string.fixedBar);//get the first part int navbar = 0;//default value int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");//get id if (resourceId > 0) {//if there is navbar = getResources().getDimensionPixelSize(resourceId);//get the dimension } float density = getResources().getDisplayMetrics().density; int barHeight = (int) ((getResources().getDisplayMetrics().heightPixels - navbar - 44) / density); css += ".flyout { max-height:" + barHeight + "px; overflow-y:scroll; }";//without this doen-t scroll } if (savedPreferences.getBoolean("pref_hideSponsoredPosts", false)) { css += getString(R.string.hideSponsoredPost); } //apply the customizations webViewFacebook.loadUrl( "javascript:function addStyleString(str) { var node = document.createElement('style'); node.innerHTML = " + "str; document.body.appendChild(node); } addStyleString('" + css + "');"); //finish the load super.onPageFinished(view, url); //when the page is loaded, stop the refreshing swipeRefreshLayout.setRefreshing(false); } //END management of loading }); //WebChromeClient for handling all chrome functions. webViewFacebook.setWebChromeClient(new WebChromeClient() { //to the Geolocation public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); //todo notify when the gps is used } //to upload files //!!!!!!!!!!! thanks to FaceSlim !!!!!!!!!!!!!!! // for >= Lollipop, all in one public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { /** Request permission for external storage access. * If granted it's awesome and go on, * otherwise just stop here and leave the method. */ if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // create the file where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Toast.makeText(getApplicationContext(), "Error occurred while creating the File", Toast.LENGTH_LONG).show(); } // continue only if the file was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.chooseAnImage)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); return true; } // creating image files (Lollipop only) private File createImageFile() throws IOException { String appDirectoryName = getString(R.string.app_name).replace(" ", ""); File imageStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appDirectoryName); if (!imageStorageDir.exists()) { //noinspection ResultOfMethodCallIgnored imageStorageDir.mkdirs(); } // create an image file name imageStorageDir = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg"); return imageStorageDir; } // openFileChooser for Android 3.0+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) { String appDirectoryName = getString(R.string.app_name).replace(" ", ""); mUploadMessage = uploadMsg; try { File imageStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), appDirectoryName); if (!imageStorageDir.exists()) { //noinspection ResultOfMethodCallIgnored imageStorageDir.mkdirs(); } File file = new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg"); mCapturedImageURI = Uri.fromFile(file); // save to the private variable final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); //captureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); Intent chooserIntent = Intent.createChooser(i, getString(R.string.chooseAnImage)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] { captureIntent }); startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); } catch (Exception e) { Toast.makeText(getApplicationContext(), ("Camera Exception"), Toast.LENGTH_LONG).show(); } } // openFileChooser for other Android versions /** * may not work on KitKat due to lack of implementation of openFileChooser() or onShowFileChooser() * https://code.google.com/p/android/issues/detail?id=62220 * however newer versions of KitKat fixed it on some devices */ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { openFileChooser(uploadMsg, acceptType); } }); // OnLongClickListener for detecting long clicks on links and images // !!!!!!!!!!! thanks to FaceSlim !!!!!!!!!!!!!!! webViewFacebook.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // activate long clicks on links and image links according to settings if (true) { WebView.HitTestResult result = webViewFacebook.getHitTestResult(); if (result.getType() == WebView.HitTestResult.SRC_ANCHOR_TYPE || result.getType() == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { Message msg = linkHandler.obtainMessage(); webViewFacebook.requestFocusNodeHref(msg); return true; } } return false; } }); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }