Android KitKat securityException when trying to read from MediaStore

Had the same problem for the last couple of days. Tried a few solutions, but for some reason I was getting permission denial on Uri content provider for some images even when I had the android.permission.MANAGE_DOCUMENTS permission added to my manifest. Here’s a workaround, for the time being: i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, CHOOSE_IMAGE); … Read more

How does evaluateJavascript work?

There is an example of the evaluateJavascript method being used in this sample: https://github.com/GoogleChrome/chromium-webview-samples/tree/master/jsinterface-example Essentially if the javascript you execute in the WebView returns a value it’ll be passed in the callback. The main thing to note is that the String returned in OnReceiveValue is either a JSON Value, JSON Object or JSON Array depending … Read more

How to Print PDF using Android 4.4 Printing framework [closed]

After spend some hours on google i found the solution. PrintManager printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE); String jobName = this.getString(R.string.app_name) + ” Document”; printManager.print(jobName, pda, null); PrintDocumentAdapter pda = new PrintDocumentAdapter(){ @Override public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback){ InputStream input = null; OutputStream output = null; try { input = new FileInputStream(file … Read more

HTML file input in android webview (android 4.4, kitkat)

Update 2: There is a simpler plugin to use with phonegap/cordova https://github.com/MaginSoft/MFileChooser Update: Sample project with Cesidio DiBenedetto plugin https://github.com/jcesarmobile/FileBrowserAndroidTest I opened an issue on the android open source project and the answer was: Status: WorkingAsIntended unfortunately, openFileChooser is not a public API. We are working on a public API in future releases of Android. … Read more

execute shell command from android

You should grab the standard input of the su process just launched and write down the command there, otherwise you are running the commands with the current UID. Try something like this: try{ Process su = Runtime.getRuntime().exec(“su”); DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); outputStream.writeBytes(“screenrecord –time-limit 10 /sdcard/MyVideo.mp4\n”); outputStream.flush(); outputStream.writeBytes(“exit\n”); outputStream.flush(); su.waitFor(); }catch(IOException e){ throw new Exception(e); … Read more

Get real path from URI, Android KitKat new storage access framework [duplicate]

This will get the file path from the MediaProvider, DownloadsProvider, and ExternalStorageProvider, while falling back to the unofficial ContentProvider method you mention. /** * Get a file path from a Uri. This will get the the path for Storage Access * Framework Documents, as well as the _data field for the MediaStore and * other … Read more