When I attempt to use the solution presented on SO here for dealing with large bitmaps in Android, I get an UnauthorizedAccessException at the point I'm trying to read from the file system from a location such as:
/mnt/sdcard/DCIM/Camera/IMG_20111223_122513.jpg
Is there a particular permission in my manifest I was supposed to select, or something else going on?
Well, there is always this one:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
If you're looking to display a screen-sized version of a full-resolution photograph, may I please refer you to the Android Training article on this subject.
Related
Ok This might seem like a dumb question but I'm not finding an answer.
I use to program for my old samsung S3. It's basically the device I learned to code for because it was all I had. But all the coding I was doing was old code I learned off Youtube etc.. as I'm self taught.
I recently invested in myself to learn some more modern code and to do things I couldn't do with my old equipment and I have run into trouble.
I have managed to fix some things like my retrofit and Picasso not working, because of a line of code missing in the manifest, but I am stuck when it comes to the Camera app as my code doesn't work on my pixel 3 but does work on my S3.
So I have a few questions that maybe someone can help answer for me.
so my 1st question is involving saving my pictures.
private File getfile () throws IOException {
File propicturefolder = new File("sdcard/camera_pro");
if (!propicturefolder.exists())
{
propicturefolder.mkdir();
}
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String prepend = "Picture_" + timestamp + "_";
File image_file = File.createTempFile(prepend, ".jpg", propicturefolder);
return image_file;
}
As you can see in my first bit of code I'm saving the picture to the SD card. But apparently a Pixel 3 doesn't have a SD card. So I don't know where to save it? There aren't really any examples out there that explain where this goes for a pixel 3. All my old examples go to the SD card.
I have tried to google an answer for this but nothing comes up but reviews of the Pixel 3 camera. What is the correct path that I am suppose to use?
My second question is this.
On my S3 I don't have to really ask for any permissions other than in the manifest so I'm trying to understand how this whole permission thing works. In the Manifest I have.
<uses-feature
android:name="android.hardware.camera2"
android:required="true" />
But in some of the example I am looking to learn permissions I see.
<uses-permission android:name="android.permission.CAMERA" />
Am I suppose to use both of these? I had learned Camera is outdated and Camera2 is what is used. Should that be android.permission.CAMERA2?
My camera doesn't work on my Pixel 3 but the code does work on my S3. So I need to learn how to code this differently apparently.
Google doesn't really give great examples on any of this. And the web is simply flooded with a lot of the wrong way to do things aka old ways.
If anyone can explain to me the changes on how this works on API 28 so I can learn how to add the slow motion camera etc or point me to an example that isn't out dated and made for android api 28 your help would be appreciated.
I've read many posts about this but nothing seems to solve the problem.
I've created a simple app that basically consists of:
Log.d("RSE", Environment.getExternalStorageState());
Log.d("RSE", "Readable? " + Environment.getExternalStoragePublicDirectory("Movies").canRead());
It always says mounted and Readable? false
When I try to do anything more, I get a permission denied error.
I've added
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />
inside AndroidManifest.xml inside the <manifest> tag and before the <application> tag.
Depending on the device, I've personally found Environment.getExternalStorage*() to be unreliable in what it points to. In this case, it's probably pointing to the emulated storage which doesn't seem to like I/O. I ended up just using "/sdcard/Movies/" which worked far more reliably than Environment.getExternalStoragePublicDirectory("Movies") ever did.
I have no idea why but I recreated the AVD and now its readable.
What are the permissions I need in order to set a live wallpaper and get the gallery images?
you want to give two permission
android:name="android.software.live_wallpaper" />
android:permission="android.permission.BIND_WALLPAPER">
For live wallpaper, place the below in your service tag in manifest.xml.
android:permission="android.permission.BIND_WALLPAPER
android:name="android.software.live_wallpaper
And for Gallery, here is the link.
Which are the permission i given to set live wallpaper and i cant get
gallery images
If your questions are interconnected, then permissions have nothing to do with you not being able to get gallery images
If these are two independent questions, I would suggest:
Start with a good tuturial. For example: http://www.vogella.com/articles/AndroidLiveWallpaper/article.html
Post the a separate question regarding getting gallery images in your app.
Anyway, to answer the question about permissions alone, depending on how you configure your application,
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.BIND_WALLPAPER" />
Why I say depending on how you confihure your application is beacuse of this. If you look at the Vogella tutorial linked, the permission android:permission="android.permission.BIND_WALLPAPER" > is declared in the service in the application attribute.
If you look at this tutorial: http://www.codeproject.com/Articles/108390/How-To-Create-Android-Live-Wallpaper, it has the permission set to the application tag.
Here is (yet) another tutorial: http://mobile.tutsplus.com/tutorials/android/creating-live-wallpapers-on-android/
I am trying to implement the best practices described in Loading Bitmaps effeciently
I've run into trouble because this line:
Utils.getExternalCacheDir(context)
inside of DiskLruCache.java is returning null, which means I get NullPointerException when I try to call .getPath()
Despite the somewhat cryptic NullPointerException that gets thrown the actual issues is that my application did not have WRITE_EXTERNAL permission, so the system was rejecting my attempt to use the ExternalDir for caching. Unfortunately this was happening at a low enough level in the code used in Displaying Bitmaps Effeciently that the Exception does not indicate SecurityException as it normally would if one were trying to write to the SD card without the proper permission.
To fix simply add this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
to your manifest.
This can also happen if you're running on a device or emulator without any external storage.
I have to parse the logcat output for my android application.So i wanted to know logcat content. I surfed a lot but i don't a proper answer. what are the logcat contents and when the system writes the logcat file?
Thanks
Pushpa
There's no api that I know of to read the logcat directly into your program. The easiest thing to do is to run logcat externally from your app and collect the results. One example of how to do that is here (see LogcatProcessor.java). Another, more elaborate, version is here (see SendLogActivity.java).
You will need this line in your manifest:
<uses-permission android:name="android.permission.READ_LOGS" />