Firstly, we know that the “Media -> Take Photo” action will open the camera with custom parameters and then take photo automatically. Unfortunately, we can’t use this action to open the camera with custom parameters just for preview, then take photo manually.
I know a specific intent, which named “android.media.action.IMAGE_CAPTURE” in android, can launch the camera app with preview window. I’ve tried it before. And I find it not support camera parameters. I mean that it only open the camera window with default settings which we can’t change it programmatically.
Below shows the intent I tried:
Send Intent [ Action:android.media.action.IMAGE_CAPTURE Cat:Default Mime Type: Data: Extra: Extra: Package:com.android.camera Class:com.android.camera.Camera Target:Activity ]
As everyone knows, most settings are stored in the format of file, even databases. After some digging, I found the file (data/data/com.android.camera/shared_prefs/com.android.camera_xiaomi_preferences_0.xml) contains the “picture size” setting. We can change the value of “pref_camera_picturesize_key” node in the xml file programmatically. Then we launch the camera app. At last, we can restore the “picture size” setting.
Be careful! If you only follow these steps, the loaded camera app will not meet the desired effect. Because the camera app maybe can’t realize some settings changed, I think. There is a trick that you can disable and enable the app to take into effect. It’s very probably that the app will re-read the preferences file after the disable and enable operation. I guess the camera app read the settings and always runs in background when the device boots. We can disable and enable an app manually in android.
Of course, we can do this with the “Secure Setting” plugin for Tasker.
As for how to change the setting string in the preferences file, you can use shell script(especially “sed”, “awk” command) or use two files for renaming and swapping.
Here is the flowchart of the whole idea. (I've tried it successfully in MIUI 3.9.6)







