How set any application as default from my application? - java

I'm write launcher switcher. Android show list of installed launchers when I press HOME button. How hide this list or get Home button press event?

What you want is not possible, for obvious security reasons. A malware author could use this feature to replace XYZ app with their own fake XYZ app to attempt to steal private information, without the user's knowledge.

I have solved this issue. I used the method addPreferredActivity of the PowerManager to set default launcher. This method is deprecated and requires a platform key, but I have not found any other way.

Related

Check if an app has been opened and recive some alert about it

I’m working on an app that can "disable" another apps for a limited time. In the first activity the user can choose which application he wants to disable, then my application needs to check if the chosen apps have been opened. If so, my app needs to detect it and show the “disabled app” activity of my app instead.
My problem is how my app can detect that the disabled app has been opened.
I looked for solutions and found this one and this one, but they were removed.
Thank you!
There is an API you can use to query events about apps (packages) but it requires an additional 'special access' permission . Have a look at UsageStatsManager

Block some selected Menu-Points in Android for Parental Control

Is it possible to build a Android-App,
where a User can control or block some selected menu-points in the default Android Settings menu? For example Connections or Display.
Sorry, I am completley new in Android Development. I want to develop an app for Parental Control.
Thank you :-)
Iam learning Kotlin
No there's no way to do this. And remember- there isn't one settings app. Multiple OEMs write their own, or customize the base one. So even if you could do it in the AOSP version, there's no way to be sure that the others would work with it. If you need this for personal use, consider a custom ROM or replacing the settings app yourself. If this is for a store app, its just not going to work, look into device ownership and device profiles as the only real way to prevent (some) settings changes.

JNativeHook home windows key

I've searched a lot but I didn't find any anwser to my issue.
I recently discovered JNativeHook and I use it to bring to the foreground an application window when I click on a key, even if the application has not the focus. Everything works good when I use keys like "a" or "f" but what I want is to use the "left-home" key of my keyboard.
The problem is when I do that, the windows menu appears but not my application which blinks in orange on the bottom launcher bar.
I think this is a normal behavior since the windows menu has a stronger priority than my application.
Do you think there is a possibility to override the default home button behavior? What I need is to bring to the front my application from elsewhere when I clicked on the left-home button.
Thanks for your replies,
JNativeHook is getting a passive keyboard input from the operating system. If you press the Windows Key, the OS will bring up the menu if it receives that event. If you want to prevent that behavior, you must consume the event before the OS receives it. You can check the Wiki article for unsupported method of consuming events on Windows and OS X.
I've had the same issue with CTRL and similar keys, you just have to run the program using an administrator command prompt (or with sudo-access on Linux)
It won't work if you're using Windows Terminal on Windows 10 though, you have to use CMD, also if you want your end-user to only use the program using administrative privileges, you'd have to add a manifest to your wrapper (You can do that in Launch4J afaik)

Open the phone default launcher when clicking a button

I want to open the phone default launcher, where all the phone's applications are displayed, whenever i click my button.
I've tried to look up for an answer but i couldn't find one,
Is that even possible?
Maybe by passing a category to an intent?
To open the Menu, (as per original question):
Use Activity.openOptionsMenu() method in the OnClickListener of the button
Edit:
Edited question as per OP's comments to open launcher, please refer solution at
How to redirect User to default launcher in an android app?

Home button brings back to my app

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.

Categories