List of usage examples for android.content Intent EXTRA_TITLE
String EXTRA_TITLE
To view the source code for android.content Intent EXTRA_TITLE.
Click Source Link
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 ava2 s . co m 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(); }
From source file:com.slim.turboeditor.activity.MainActivity.java
public void saveTheFile(final boolean saveAs) { if (!saveAs && mFile != null && mFile.exists()) { Observable<Boolean> saveFile = getSaveFileObservable(getApplicationContext(), mFile, pageSystem.getAllText(mEditor.getText().toString()), currentEncoding) .subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).cache(); saveFile.subscribe(new Action1<Boolean>() { @Override//from w w w. j a va 2s. com public void call(Boolean aBoolean) { Log.d("call(" + aBoolean + ")"); savedAFile(aBoolean); } }); } else { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_TITLE, mFile.getName()); startActivityForResult(intent, SAVE_AS_REQUEST_CODE); } }
From source file:org.mklab.mikity.android.MainActivity.java
/** * ?????????/*w ww.j av a 2 s .c om*/ */ public void sendFileChooseIntentForSavingModel() { final Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.setType("*/*"); //$NON-NLS-1$ intent.putExtra(Intent.EXTRA_TITLE, "temp.m3d"); //$NON-NLS-1$ startActivityForResult(intent, REQUEST_CODE_SAVE_MODEL_DATA_FILE); }
From source file:org.kontalk.util.MediaStorage.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static void createFile(Fragment fragment, String mimeType, String fileName, int requestCode) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); // Filter to only show results that can be "opened", such as // a file (as opposed to a list of contacts or timezones). intent.addCategory(Intent.CATEGORY_OPENABLE); // Create a file with the requested MIME type. intent.setType(mimeType);//w w w .ja v a 2 s .c o m // Note: This is not documented, but works intent.putExtra("android.content.extra.SHOW_ADVANCED", true); intent.putExtra(Intent.EXTRA_TITLE, fileName); fragment.startActivityForResult(intent, requestCode); }
From source file:com.farmerbb.notepad.activity.MainActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void reallyExportNotes() { String filename = ""; try {/*from w w w. ja va 2 s.c om*/ filename = loadNoteTitle(filesToExport[fileBeingExported].toString()); } catch (IOException e) { /* Gracefully fail */ } Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TITLE, generateFilename(filename)); try { startActivityForResult(intent, EXPORT); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
@Override protected WebView createViewInstance(final ThemedReactContext reactContext) { final ReactWebView webView = new ReactWebView(reactContext); /**//w ww.ja va 2 s.c om * cookie? * 5.0???cookie,5.0?false * */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true); } webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); reactContext.getCurrentActivity().startActivity(intent); // DownloadManager.Request request = new DownloadManager.Request( // Uri.parse(url)); // // request.setMimeType(mimetype); // String cookies = CookieManager.getInstance().getCookie(url); // request.addRequestHeader("cookie", cookies); // request.addRequestHeader("User-Agent", userAgent); // request.allowScanningByMediaScanner(); //// request.setTitle() // request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! // request.setDestinationInExternalPublicDir( // Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName( // url, contentDisposition, mimetype)); // DownloadManager dm = (DownloadManager) reactContext.getCurrentActivity().getSystemService(DOWNLOAD_SERVICE); // dm.enqueue(request); // Toast.makeText(reactContext, "...", //To notify the Client that the file is being downloaded // Toast.LENGTH_LONG).show(); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage message) { if (ReactBuildConfig.DEBUG) { return super.onConsoleMessage(message); } // Ignore console logs in non debug builds. return true; } @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File imageFile = new File(storageDir, /* directory */ imageFileName + ".jpg" /* filename */ ); return imageFile; } public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent .resolveActivity(reactContext.getCurrentActivity().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 FLog.e(ReactConstants.TAG, "Unable to create Image File", ex); } // 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("*/*"); 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, "?"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); reactContext.getCurrentActivity().startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); // final Intent galleryIntent = new Intent(Intent.ACTION_PICK); // galleryIntent.setType("image/*"); // final Intent chooserIntent = Intent.createChooser(galleryIntent, "Choose File"); // reactContext.getCurrentActivity().startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } @Override public void onShowCustomView(View view, CustomViewCallback callback) { if (mVideoView != null) { callback.onCustomViewHidden(); return; } // Store the view and it's callback for later, so we can dispose of them correctly mVideoView = view; mCustomViewCallback = callback; view.setBackgroundColor(Color.BLACK); getRootView().addView(view, FULLSCREEN_LAYOUT_PARAMS); webView.setVisibility(View.GONE); UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { // If the status bar is translucent hook into the window insets calculations // and consume all the top insets so no padding will be added under the status bar. View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); decorView.setOnApplyWindowInsetsListener(null); ViewCompat.requestApplyInsets(decorView); } }); reactContext.getCurrentActivity() .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } @Override public void onHideCustomView() { if (mVideoView == null) { return; } mVideoView.setVisibility(View.GONE); getRootView().removeView(mVideoView); mVideoView = null; mCustomViewCallback.onCustomViewHidden(); webView.setVisibility(View.VISIBLE); // View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); // // Show Status Bar. // int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; // decorView.setSystemUiVisibility(uiOptions); UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { // If the status bar is translucent hook into the window insets calculations // and consume all the top insets so no padding will be added under the status bar. View decorView = reactContext.getCurrentActivity().getWindow().getDecorView(); // decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { // @Override // public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // WindowInsets defaultInsets = v.onApplyWindowInsets(insets); // return defaultInsets.replaceSystemWindowInsets( // defaultInsets.getSystemWindowInsetLeft(), // 0, // defaultInsets.getSystemWindowInsetRight(), // defaultInsets.getSystemWindowInsetBottom()); // } // }); decorView.setOnApplyWindowInsetsListener(null); ViewCompat.requestApplyInsets(decorView); } }); reactContext.getCurrentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } private ViewGroup getRootView() { return ((ViewGroup) reactContext.getCurrentActivity().findViewById(android.R.id.content)); } }); reactContext.addLifecycleEventListener(webView); reactContext.addActivityEventListener(new ActivityEventListener() { @Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) { return; } Uri[] results = null; // Check that the response is a good one if (resultCode == Activity.RESULT_OK) { if (data == null) { // If there is not data, then we may have taken a photo if (mCameraPhotoPath != null) { results = new Uri[] { Uri.parse(mCameraPhotoPath) }; } } else { String dataString = data.getDataString(); if (dataString != null) { results = new Uri[] { Uri.parse(dataString) }; } } } if (results == null) { mFilePathCallback.onReceiveValue(new Uri[] {}); } else { mFilePathCallback.onReceiveValue(results); } mFilePathCallback = null; return; } @Override public void onNewIntent(Intent intent) { } }); mWebViewConfig.configWebView(webView); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setDefaultFontSize(16); webView.getSettings().setTextZoom(100); // Fixes broken full-screen modals/galleries due to body height being 0. webView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } return webView; }
From source file:org.tlhInganHol.android.klingonassistant.EntryActivity.java
private void setShareEntryIntent(KlingonContentProvider.Entry entry) { if (entry.isAlternativeSpelling()) { return;/*w ww .j a v a 2 s .co m*/ } Resources resources = getResources(); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); mShareEntryIntent = new Intent(Intent.ACTION_SEND); if (sharedPrefs.getBoolean(Preferences.KEY_KLINGON_UI_CHECKBOX_PREFERENCE, /* default */false)) { mShareEntryIntent.putExtra(Intent.EXTRA_TITLE, resources.getString(R.string.share_popup_title_tlh)); } else { mShareEntryIntent.putExtra(Intent.EXTRA_TITLE, resources.getString(R.string.share_popup_title)); } mShareEntryIntent.setType("text/plain"); String subject = "{" + entry.getFormattedEntryName(/* isHtml */false) + "}"; mShareEntryIntent.putExtra(Intent.EXTRA_SUBJECT, subject); String snippet = subject + "\n" + entry.getFormattedDefinition(/* isHtml */false); mShareEntryIntent.putExtra(Intent.EXTRA_TEXT, snippet + "\n\n" + resources.getString(R.string.shared_from)); }
From source file:com.anjalimacwan.MainActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) private void reallyExportNote() { String filename = ""; try {//from w w w . ja v a2s . c o m filename = loadNoteTitle(filesToExport[fileBeingExported].toString()); } catch (IOException e) { /* Gracefully fail */ } Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TITLE, generateFilename(filename)); try { startActivityForResult(intent, EXPORT); } catch (ActivityNotFoundException e) { showToast(R.string.error_exporting_notes); } }
From source file:org.schabi.newpipe.detail.VideoItemDetailFragment.java
private void setupActionBarHandler(final StreamInfo info) { actionBarHandler.setupStreamList(info.video_streams); actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() { @Override// w w w.ja va2 s . c om public void onActionSelected(int selectedStreamId) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, info.webpage_url); intent.setType("text/plain"); activity.startActivity( Intent.createChooser(intent, activity.getString(R.string.share_dialog_title))); } }); actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() { @Override public void onActionSelected(int selectedStreamId) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(info.webpage_url)); activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.choose_browser))); } }); actionBarHandler.setOnPlayWithKodiListener(new ActionBarHandler.OnActionListener() { @Override public void onActionSelected(int selectedStreamId) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setPackage(KORE_PACKET); intent.setData(Uri.parse(info.webpage_url.replace("https", "http"))); activity.startActivity(intent); } catch (Exception e) { e.printStackTrace(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(R.string.kore_not_found) .setPositiveButton(R.string.install, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(activity.getString(R.string.fdroid_kore_url))); activity.startActivity(intent); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); } } }); actionBarHandler.setOnDownloadListener(new ActionBarHandler.OnActionListener() { @Override public void onActionSelected(int selectedStreamId) { try { Bundle args = new Bundle(); // Sometimes it may be that some information is not available due to changes fo the // website which was crawled. Then the ui has to understand this and act right. if (info.audio_streams != null) { AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info)); String audioSuffix = "." + MediaFormat.getSuffixById(audioStream.format); args.putString(DownloadDialog.AUDIO_URL, audioStream.url); args.putString(DownloadDialog.FILE_SUFFIX_AUDIO, audioSuffix); } if (info.video_streams != null) { VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId); String videoSuffix = "." + MediaFormat.getSuffixById(selectedStreamItem.format); args.putString(DownloadDialog.FILE_SUFFIX_VIDEO, videoSuffix); args.putString(DownloadDialog.VIDEO_URL, selectedStreamItem.url); } args.putString(DownloadDialog.TITLE, info.title); DownloadDialog downloadDialog = DownloadDialog.newInstance(args); downloadDialog.show(activity.getSupportFragmentManager(), "downloadDialog"); } catch (Exception e) { Toast.makeText(VideoItemDetailFragment.this.getActivity(), R.string.could_not_setup_download_menu, Toast.LENGTH_LONG).show(); e.printStackTrace(); } } }); if (info.audio_streams == null) { actionBarHandler.showAudioAction(false); } else { actionBarHandler.setOnPlayAudioListener(new ActionBarHandler.OnActionListener() { @Override public void onActionSelected(int selectedStreamId) { boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity) .getBoolean(activity.getString(R.string.use_external_audio_player_key), false); Intent intent; AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info)); if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 18) { //internal music player: explicit intent if (!BackgroundPlayer.isRunning && streamThumbnail != null) { ActivityCommunicator.getCommunicator().backgroundPlayerThumbnail = streamThumbnail; intent = new Intent(activity, BackgroundPlayer.class); intent.setAction(Intent.ACTION_VIEW); Log.i(TAG, "audioStream is null:" + (audioStream == null)); Log.i(TAG, "audioStream.url is null:" + (audioStream.url == null)); intent.setDataAndType(Uri.parse(audioStream.url), MediaFormat.getMimeById(audioStream.format)); intent.putExtra(BackgroundPlayer.TITLE, info.title); intent.putExtra(BackgroundPlayer.WEB_URL, info.webpage_url); intent.putExtra(BackgroundPlayer.SERVICE_ID, streamingServiceId); intent.putExtra(BackgroundPlayer.CHANNEL_NAME, info.uploader); activity.startService(intent); } } else { intent = new Intent(); try { intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(audioStream.url), MediaFormat.getMimeById(audioStream.format)); intent.putExtra(Intent.EXTRA_TITLE, info.title); intent.putExtra("title", info.title); // HERE !!! activity.startActivity(intent); } catch (Exception e) { e.printStackTrace(); AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(R.string.no_player_found) .setPositiveButton(R.string.install, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(activity.getString(R.string.fdroid_vlc_url))); activity.startActivity(intent); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.i(TAG, "You unlocked a secret unicorn."); } }); builder.create().show(); Log.e(TAG, "Either no Streaming player for audio was installed, or something important crashed:"); e.printStackTrace(); } } } }); } }
From source file:android_network.hetnet.vpn_service.ActivityLog.java
private Intent getIntentPCAPDocument() { Intent intent;/* w ww. j a v a 2s . c o m*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { if (Util.isPackageInstalled("org.openintents.filemanager", this)) { intent = new Intent("org.openintents.action.PICK_DIRECTORY"); } else { intent = new Intent(Intent.ACTION_VIEW); intent.setData( Uri.parse("https://play.google.com/store/apps/details?id=org.openintents.filemanager")); } } else { intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/octet-stream"); intent.putExtra(Intent.EXTRA_TITLE, "netguard_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".pcap"); } return intent; }