Keeping Camera Alive While Paused - java

I have a flashlight app, and if the app is paused, the camera is released. Be it the home button or power button. I want the camera to stay alive when either of these are pressed and released when I close the app completely. How do I go about doing this?

This is intended functionality to ensure you do not consume more power than necessary, and that other software on the device can obtain access to the camera on demand. Some useful information on the Activity lifecycle can be found here.
Generally, an Android developer's options are:
Build a custom Android firmware that gives your app privileged
access to the camera. This option is usually only really feasible if
you are providing dedicated hardware, with this firmware and your app
pre-installed.
Approach your app design in a different way, that does
not require the use of the camera when it is not in the foreground.
Stick with the existing behaviour, and detail the caveats to the user on the market (and possibly as a first-time pop-up dialog to grab their attention) to reduce the number of complaints.

Related

Camera intent open the camera app (only the first time)

Here is the context:
In my app, I need to capture images, that's why I use camera intent.
This feature works perfectly, but only if the camera app was already been opened once before
Indeed, this issue appears only on a new device, or a new emulator
Here is the problem:
When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures. That's not the camera app IN my app, but the camera app alone. I need to close this camera app, back to my app, and trying again
When I visit the camera app at least one time in the device's life, there is no issue
Here is what I'm looking for:
I want this camera app open in my app, even if it's the first time
I use the classic and official way to captures images
https://developer.android.com/training/camera/photobasics
EDIT
I think the problem is because at the first time, the camera app asked for the location permission. So we need to open the intent without asking this permission, to keep the focus
When I want to capture an image, the native camera app just open, giving to me some hints to how take pictures.
There are ~26,000 Android device models. These ship with dozens, if not hundreds, of different pre-installed camera apps. The behavior of any of those apps on first run of that app will vary by app. Moreover, the decision of how those apps behave when they are first run is up to the developers of those apps, not you or me.
That's not the camera app IN my app, but the camera app alone
It is never "IN [your] app" if you are using ACTION_IMAGE_CAPTURE, as your question suggests that you are. It is always a third-party app, one of many pre-installed ones, or one of the user ones. And, again, the behavior of those apps are up to their respective developers.
I want this camera app open in my app, even if it's the first time
Sorry, but that is not under your control.

Is there a way to make bundled/grouped Android notifications expand on tap, rather than launching an activity in the app?

I intend to interact with Android notifications simply through the on tap events of each, rather than having an activity listing them out inside the app, this is why I'm asking if there is a way to just expand the grouped notifications on tap (not just on the arrow) so that they can be tapped individually. This would mirror the behavior of other mobile platforms and would be nice and fast to have.
This is for Android phones with no real api limits, I'll do what I can to find a workaround if the solution is for a higher api level.

How to make an app unclosable?

After a user opens my application I don't want them to be able to get out. So when they press the home or back button it doesn't let them exit the app. I know there are ways using a service to keep the app always running in the background, but I don't even want them to even exit.
Is this even possible, if so how? Without having to hack the kernel.
I know this sounds odd, but it is not for a commercial app, but for my lab, it will never be on GooglePlay. The tablets will be given to little kids and they will take a test on it, so I can't have them using youtube or anything else.
Related post: Android, How to make the task of the app unclosable? Only closable by task killing
The answer by CommonWare seems to indicate that kernel hacking is the only way, but is it?
Also I am using Android L.
there is no official support yet - there will be support with android L via the Task locking API
The L Developer Preview introduces a new task locking API that lets
you temporarily restrict users from leaving your app or being
interrupted by notifications. This could be used, for example, if you
are developing an education app to support high stakes assessment
requirements on Android. Once your app activates this mode, users will
not be able to see notifications, access other apps, or return to the
Home screen, until your app exits the mode.
https://developer.android.com/preview/api-overview.html
EDIT: as you said you use L this got obsolete - but I leave it here as a hint for others
said that - you are also able to get this kind of work without root today if you have to ( e.g. kiosk mode app on a certain hardware ). It is not simple - and no solution that works for all devices - but if you need it you can get it work with tricks like:
- reacting on home-screen intent ( and setting it as default )
- when you go to background - bring your self foreground again
- ..
It seems google has some thing called COSU for setting up single-purpose devices
Android 5.0 Lollipop introduced two new ways to configure Android
devices for a single purpose:
With app pinning, the device user can temporarily pin specific apps to the screen.
With lock task mode, a user can’t escape the app and the Home and Recents buttons are hidden. Additionally, lock task mode gives the IT
administrator a more robust way to manage COSU devices, as discussed
below.
and
As an IT administrator, you can configure Android 6.0 Marshmallow and
later devices as corporate-owned, single-use (COSU) devices. These are
Android devices used for a single purpose, such as digital signage,
ticket printing, point of sale, or inventory management. To use
Android devices as COSU devices, you need to develop Android apps that
your customers can manage.
from here
and there is a code lab for it here
for earlier versions of android here i founded How-To Create a Working Kiosk Mode in Android which shows some hacks for disabling buttons and restarting the application after boot and lock. note that most of these hacks, don't work on android 6 and later

SlidingTab on Lock Screen vibrates when unlocking - regardless of the global settings about haptic feedback

When unlocking my android 2.3.3 phone at the simple lock screen it vibrates once the slider is touched and a second time a little longer when the slider has been pulled completely to the other side.
I found it a little annoying and so I thought I could somehow switch it off in the settings as I can switch off any other vibration.
There are actually two categories which might make sense in this case:
1) Sound Settings/General/Vibrate with the individual settings: (always, never, only in silent mode, only when not in silent mode)
2) Sound Settings/Feedback/Haptic Feedback (on/off)
I had to find out, that none of these settings have an impact on the unlocking action mentioned above.
So I googled and found some comments about the fact, that the vibration cannot be switched off easily in the settings.
e.g.
http://code.google.com/p/android/issues/detail?id=34040
Now I got curious and I tried to dive in a little deeper into the android sources and found the source for the slider here: https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/widget/SlidingTab.java
see:
vibrate(VIBRATE_SHORT);
and:
vibrate(VIBRATE_LONG);
It seems to me that the vibrate action is called regardless of any settings.
Now I have some questions:
Shouldn't the vibration for unlocking consider the settings from either 1) or 2) above?
How would this be added to the source code and how would this change be applied to the android source repository so that some time later this could be migrated into the next android (if the sliding tab is used there at all)
Would it be possible to update the file SlidingTab.java seperately and test it on my rooted device or would it be necessary to do the complete make for the whole android system and flash my mobile phone with the new system in order to see if it works?
I have found other mobile phones with the same slider and no vibration when unlocking. I am clueless how this can be after I found the prove that it is not able to switch off the vibration in the source code.
thank you for sharing your knowledge with me
Nils
It may be consider or may not.
Not sure here.
If you need to change lock screen at all you can find various implementation. If you need to change default lock screen you need to build entire system.
Every companies customise Android for the phones. Therefore some sliders may have no vibration. Or the phone may have no hardware for it.

Accessing hardware buttons within the camera app

i wish to write a plugin that will enable me to access hardware buttons of the phone while using the camera app. how would i go about doing this. or is it even possible.
Sorry, you can't generally do this. There are some keys that applications can respond to while in the background (specifically the media play/pause/etc buttons) but it is not generally possible to process key events while another app has focus.
Your best best is to check the Camera source but you might consider making your own app based on Camera.

Categories

Resources