I want to develop a custom launcher android for Samsung Tablet where user can only exit the launcher with a passcode input.
Currently I face problem in recent app button. If user click recent app button, and then click the recent app, then click backpressed, device will go to TouchWiz launcher even I already set my launcher as a default launcher. Also, I disable the notification bar so user can't access it. However, when it go to TouchWiz via backpressed at recent app, the notification also disable, it should be able when in TouchWiz launcher.
My proposed solution is to detect when user click recent app and forbid any action that can cause the changes of current view.
You can check onWindowFocusChanged method. You Activity will get a callback on this method when you click recent apps or press back button from it. When you click on recent apps hasFocus will be false and when you press back it will be true.
documentation
I can't detect the recent app clicked. So I use onPause() to detect if my app is on foreground or background. If is in onPause() then my app is on background, if so, I do startActivity(myLauncher) so other app won't launched.
Related
I am calling a flutter module/aar from my Android app. I used an intent which will be created after a button press which starts a flutter module/aar.
Its working fine but I can't find any documentation guiding how to exit from flutter and start some other android intent or navigate back to previous android screen buy doing say a button press (without pressing back button).
You can use the SystemNavigator.pop() method:
Removes the topmost Flutter instance, presenting what was before it.
On Android, removes this activity from the stack and returns to the previous activity.
Hi i need something to don't let users exit my app without pressing the button exit. Basicly if they use home or any other button the app can't exit. How can i make this? Im using android studio and im new to this language.
The only thing you can do is override the onBackPressed method but unfortunately, you can't stop the home button from closing the app unless the phone is rooted or something. But when you do close the app with the home button it is still in Android's memory which prevents cold starts the next time the user opens the app. I am not sure why the information would be helpful though.
I have an app for a customer (refer to it as "their" app). When "their" app is open they do not want users of the device to use any other apps.
The only way they want to get round this, is if i create a login page within the app, and from there you can go to the android settings page. If the android settings are accessed, then the user should be able to go anywhere they want, until "their" app is in the foreground again, then the device should be locked into using just that app.
If this makes any difference, "their" app is a cordova app. I dont think it will, but thought i would mention it anyway. Needs to work in android 5.0
Is this possible at all? What would i need to implement for this? A service and timer?
UPDATE
It is a tablet, so it will never ring.
If the user presses the Home button, nothing should happen as the app should stay in the foreground
I am making a car launcher application, which contains shortcuts to other apps, when i'm in another app i'd like to press the home button and go back to my launcher
So basically i need to override the home button outside of my app,the override has to work only when my app is opened in the background so when i close my app the home button will work as usual taking you to your default launcher
Can i implement something like this or i'm asking too much?
There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.
In short, no it's not possible, and even if it were, it is a serious disruption in what a user expects out of an app's behavior.
If you go the route of making your app act be a replacement home screen you'll have to include in the install instructions for the users to set your app as the default launcher.
Then the home button would take them to your app. In order to get it to switch back to the default launcher when they are not in "car" mode would be a bit tricky but you could prolly achieve it with some sort of fork activity that checks if car mode is enabled if so go to your car mode launcher if not go to the default launcher (it gets trickier if the user already has a different 3rd party launcher) So essentially your app will always be the home screen app no matter if car mode is enabled or not, but if it is not then you manually start the "normal" home screen.
I have a simple application that has a button that allows the user to enter the camera application by clicking it. It seems that things work fine if I were to take a picture having the tablet in landscape mode. It prompts the user to save or discard. After clicking save, it returns to my application.
However, when I attempted to capture a photo with a portrait mode, after clicking the save button, it will return to the camera application again.
Why is this so?
It has nothing to do with your application. By firing intent you are invoking camera application present on your device. Its behaviour out of your reach