How to limit duration of MediaStore in Android 7 - android

What's new with duration limit of MediaStore in Android 7? There is nothing about it in documentation, but since sdk version 24 a device records a video without any limit.
final Activity activity = (Activity) context;
String controlId = videoInput.getControlId();
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (videoInput.getMaxDuration() > 0) {
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoInput.getMaxDuration());
}
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, videoInput.getRecordQuality().ordinal());
int requestCode = ActivityResultBus.getInstance().generateRequestCode(new SBundle(controlId));
activity.startActivityForResult(intent, requestCode);
I tested it on a real Motorola Nexus 6 with Android 7.0 and on virtual devices with 7.0 and 7.1.1. On previous versions all works as I want.
Mb something wrong with my extras bundle?

"There is no requirement for any camera app to honor EXTRA_DURATION_LIMIT. This is a request, not a command"
Any other way to limit the length of video ?
Not when you delegate the work to a third-party app. You are welcome to use the camera APIs and record the video directly yourself. Or, if your concern is not with the video on the device but some subset that you need to upload, look into how you can chop off the first 10 seconds of the video, and upload that piece.
This answer is directly compiled from this question : MediaStore.EXTRA_DURATION_LIMIT Not working Nexus Devices?

Related

Code works fine in emulator but gives error in real device?

I am building a chat app and I am using one account on emulator (Google Pixel 2 Api 30) and second on Realme 5 (Android 10). Now I have to choose multiple images from gallery so I use this piece of code.
Intent i = new Intent();
i.setType("image/*");
i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
i.setAction(Intent.ACTION_PICK);
startActivityForResult(i, PICK_IMAGE_MULTIPLE);
Now this code works perfectly fine in emulator but gives error in Realme 5.
Note: I don't know what error it gives on real device. The app just gets back to starting activity.

Slow MapEngine initialization when offline maps are on SDCard on Heremaps API (Android)

I'm having quite a problem here:
I want to have all Europe maps on my devices, but they don't have enough internal storage to have them all, so I'm using an SD-Card to store them.
The problem is when initializing the MapEngine [MapEngine.getInstance().init(...)] it takes a lot of time to load(until the OnEngineInitListener is executed) on older devices ( an Honor 5X [huawei KIW-L24] for the old device with android 6.0.1, but it's quite random, it usually takes about 23 seconds but sometimes it may take 2 seconds other it may take up to 1 minute and a half.
So, I tried to profile the app on android studio, and it gets stuck on the method com.nokia.maps.MapServiceClient.startServer, as shown on the attached image:
Honor 5X Android Profiler Sample
I tried to factory reset the phone and even tried on other honor 5x phones, and the same problem is happening.
On logcat I get this error just before the OnEngineInitListener starts ( with WiFi connected, disconnected and with WiFi disabled):
24442-24442/net.gottsolutions.gps E/WifiManager: WifiServiceMessenger == null
On the other side, I tested the same app, and the same SDCard on a Nokia 4.2 (Android 9.0) and it took about 2 seconds to start that method.
So I decided to test your app (Here WeGo), with the Europe maps on SDCard, and I got a similar problem like on the GPS I'm developing.
Video attached:
https://youtu.be/YH7w9p0NeCs
Another problem is when initializing the MapEngine it is blocking the UI, even if it is started on another thread or background service.
The SDCard I'm using is a Kingston 32GB UHS I.
MapEngine.getInstance().init(sdkAppContextApplicationContext, error ->
{
if (error == OnEngineInitListener.Error.NONE)
{
if (ISDKMapEngineListener != null)
ISDKMapEngineListener.onSDKReady();
} else
{
Log.e("MapEngine", "Failed to initialize MapEngine: " + error);
}
});
Can you please try to pass context in turnOnWifi() like turnOnWifi(sdkAppContextApplicationContext) from MainActivity
wifi_manager =(WifiManager)sdkAppContextApplicationContext.getSystemService(Context.WIFI_SERVICE);
wifi_manager.setWifiEnabled(true);
Thread.sleep(2000L);

Open frontal face camera in android

I'm trying to open a frontal camera on my device but nothing that I try works and the back camera is always opening. I'm using the LG G4 device.
File file;
try {
File dir = new File(Environment.getExternalStorageDirectory());
file = File.createTempFile("temp.png", dir);
} catch (IOException e) {
AndroidExceptionHandler.handle(e);
}
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
cameraIntent.putExtra("android.intent.extras.CAMERA_FACING", 1);
startActivityForResult(cameraIntent, REGISTRO_PONTO_IMAGE_CAM);
What I'm doing wrong?
You are assuming that an undocumented, unsupported Intent extra will be honored by all camera apps on all devices.
There are ~2 billion Android devices, made up of thousands of device models. Those device models will ship with hundreds of different camera apps. Users can also install camera apps themselves. Any of those hundreds of camera apps may be what handles your ACTION_IMAGE_CAPTURE request. And none of them have to honor an android.intent.extras.CAMERA_FACING extra.
You are welcome to put that extra on the Intent, and it is possible that there are camera apps that will pay attention to it. You should not assume that any camera will pay attention to it, and it will be up to the user to choose what camera to use for taking the picture.

Intent to send an SMS to multiple contactcs

Trying to initiate an intent to send an SMS to multiple recipients with the following code:
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"sms", destination, null));
However in the destination string say I have "555-555-5555,555-555-5556". The comma delimiter is working fine on a Samsung vibrant. However, this will not work on a nexus 1. On the nexus one i need to use a semicolon as the delimiter and then it works. On the nexus one, if I use commas as the delimiter, it only picks up the last phone number. If I use the semicolon, the nexus one picks up all the phone numbers however, it then breaks the vibrant. With the semicolon, the vibrant does not pick up any of the phone numbers. Any insights?
You should file feature request in android
for the public telephony api to standardize this kind of stuff.
Until now (Gingerbread 2.3.3) there is no "default character" or api do discover what is the correct for each rom.
Anyway, I suggest that you ask people do test in different roms and create switch cases in your app. It will not work in all of them, but could work in most of.
Semicolon works for other than samsung and Comma works for Samsung devices. Just put a check for:
String manufactures = android.os.Build.MANUFACTURER;
to achieve the same functionality for both samsung vs others.

Getting a list of Contacts on SenseUI 2.1?

This is simple enough on every other version of Android, including SenseUI 1.5.
//For Contacts
Intent pickIntent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
this.startActivityForResult(pickIntent, RESULT);
//For Phones
Intent pickIntent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI);
this.startActivityForResult(pickIntent, RESULT);
On SenseUI 2.1 (HTC Incredible) this shows a list of numbers (the URI number). So you get a list of 1-200 if you have 200 contacts. Selecting one of the contacts you can then gather all of the information needed.
Is there any good work around known?
Unfortunately, I do not have any solution for this issue, which also occurs on the HTC Desire, but would recommend to file a bug with HTC instead of figuring out workarounds, as this IMHO clearly is a bug in HTC's implementation.

Categories

Resources