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

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.

Related

get a location once in the background at any time Android Studio Java

I want to get the location of the device once when the service is running in the background (the tracker monitors the change in the database and then executes the code that should get the geolocation of the phone). I encountered a problem: the program receives location data when the application is running, but when it goes into the background, the location data stops being received in a few seconds. I tried all the codes and options that I could find, but everything stops working when the program goes into the background. For this I use AndroidStudio Java. So how do I implement this and is it even possible? Thanks.
On Android there are two types of Services- foreground and background. Background (the default) on modern Android are killed 2 minutes after your app is no longer in the foreground. Foreground services are kept for longer, require you to have a notification so the user knows you're tacking him (think of Uber and the notification you can't swipe away you get while its running), but can still be killed for resources if other apps need it. You cannot rely on any Service running permanently.
So the answer is going to be either Foreground Service, or its going to be a completely different architecture for your program. The second really depends on exactly when and why you want to get the location.
There are many limitations on getting on getting location in background, refer to this
Do you target API level 29 or up? if yes, have you add ACCESS_BACKGROUND_LOCATION permission in manifest? If this is not declared, app can only access location while in foreground.
Even after declaring ACCESS_BACKGROUND_LOCATION permission, app can only get location data a few time in an hour due to limitations. Maybe you can consider using foreground service instead to avoid such limitations.

Open Google Play page of my app, with navigation/search features disabled

I am developing an app with launcher features (which is also Device Admin). In my app there is a button which when pressed opens the Google Play listing for my app so that users can update to the latest version. I am using the below code to achieve this :
try {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}catch (Exception e){
e.printStackTrace();
}
Everything works fine, no problem here. Upon excecution of above code, the user is presented with this (pardon the Greek):
Due to the fact that my app should function as a launcher (in the sense that it shouldn't allow other apps to launch, and especially other launcher apps) the back button and search field pose a risk for me. In theory the user could navigate or search and download some other app other than my own as presented bellow:
So, my question is, is there a way to launch the Google Play listing of my app without the back button and search bar/icon? A page where the user can perform actions regarding my app and nothing more. No way to install other apps.
If someone comes up with an alternate approach which produces the same results, then by all means share your wisdom! But a Google Play listing of my app without the navigation/search bar on top would be the Holy Grail for me at this point! :D
Any help would be appreciated! Thank you in advance.
Some answers to anticipated questions. (Users that feel they have already read enough need not go past this point):
The app is targeted torwards a very specific demographic. It is a tool for bus drivers to print tickets using a thermal printer over Bluetooth and perform various work related tasks. The devices are not the drivers' personal devices but devices provided by their agency as work tools. The launcher features try to address an issue where drivers would consume their monthly mobile data using apps like Youtube e.t.c.
I have a Whitelist of apps that the user can freely launch. There is a service that checks which is the current app on the foreground and if it does not belong to the Whitelist, it immediately redirects the user back to my app (as there is no legit way to kill those apps on a non-rooted device). The problem with this approach is that if the app that was launced is a launcher app (let's say Nova Launcher) , then in the milliseconds that this launcher app was in the foreground before the service redirected the user back to my app, the launcher app had already presented the user with a dialog to pick the prefered launcher app for the device like the one below, thus disabling my app and gaining free access accross the device :
You can use in-app-updates to give updates to your app(but this supports API 21 and above)
Supporting API level 21 and above, the Play Core library now allows us to offer in-app updates to our users — meaning we can show that an app update is available whilst the user is within the context of our application
If your app satisfies the API level(ie minimum SDK is 21) follow this guideline to use in-app-updates

Pop-up an imageView even if app is not in foreground

I want to know if it is possible to show an imageView even if the app is not in foreground or is killed like ads are displayed after some time intervals even if the app is closed
If yes, how can we do that.
It is possible to run code even if your app is not in the foreground through using services like JobScheduler or WorkManager in Android.
This is how apps such as Alarm Apps can ring at a later time even if the app isn't opened.
However, keep in mind that it is DEFINITELY NOT OKAY for you to run ads OUTSIDE of your foreground App. To schedule for ads to appear when you're app isn't running is easily considered as behavior for malware and it's an easy ticket to getting your app killed off and potentially your Developer account closed for all eternity.
But if you want to show an Image at a later time even if your app isn't running, for legitimate purposes, then you can do so through scheduling jobs through the services I mentioned in my first line.
I repeat.
It is NOT OKAY to show ads after your app is placed in the background or after it is destroyed.
It is NOT OKAY to show ads at a later time if your app is not the foreground app.

Triggering an Application launch from bluetooth device

I have a Bluetooth device that I can connect to an android phone, and I need to launch a specific application when a certain button is pressed on the Bluetooth Device.
So on press A--> Application A needs to be opened.
As of now, I am attempting to build an android application which can scan for and connect to the bluetooth device, with a set of built-in keymaps (A->Application A, etc), and the application would open up the application corresponding to the keymap, but this approach has its limitations in that I was not able to successively select buttons to transfer between apps.
Would there be a way to directly interact with the android kernal from BlueTooth to try to directly open up desired applications?
There should be a number of ways to get what you want, depending on your circumstances. We can provide more help for specifics if you post some of the code you're currently using to start the apps. It never hurts to review the basics of using Intents to start Activities.
Just guessing, but you may need to bring the requested activity to the foreground if it has already started and something else has focus.

Making an whole app invisible even from application manager also in android

I am making one security related application in android so i am looking for three solution
1. my application should be invisible (like service or keylogger) but whole application should not be visible in setting-> application manger
2. All the activity should be visible on some secure key(predefine shortcut) pressed in mobile
3. i want access camera(front camera) without creating sound and image should be saved without preview.
No, you cannot do this on Android devices.

Categories

Resources