Triggering an Application launch from bluetooth device - java

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.

Related

Is there any way to start an activity by clicking on anyone of the devices found Bluetooth?

I'm developing an Android Studio Java app where if users are near each other, then using Bluetooth I can list the devices nearby.
I wanted to know if there is any way that on clicking on any one of the devices found, I can view that specific users profile, without connecting/paring to them.
Any insights on this could be really helpful, thanks.
I will be creating an activity where I will be able to turn Bluetooth on/off and all other Bluetooth features that we find on our mobile device also I will be creating the users profile activity and users' data will be stored in firebase database

Is it possible to know the app which is opened currently?

I am a beginner in android development. I want to know that is it possible to know the app which is opened currently. I came to know that finding the apps which are running currently through Activity Manager (getRunningTasks()) is now removed from the Android studio. So I want to know is there any other way to know? I just want to know the app which is opened and running currently on the mobile but not the apps running in the background Could somebody please help me in this case?
You can use AccessibilityService to get event notification. But AccessibilityService are specifically for accessibility uses. If you use the service for other purposes, then the application will more likely to be downed/removed for PlayStore due to policies. Another viable option is UsageStatsManager, but with some limitations.
UsageStatsManager is not push event based system. You have to poll in few mills(depends upon the use-case)
Usage Access Permission grant/deny is not straight forward. You have to start Setting Activity with Settings#ACTION_USAGE_ACCESS_SETTINGS action and have to rely on the users understanding of how to grant permission(Since permission list may contain other applications).

Clear other apps data programmatically?

I am developing an android application and i need clear the data of another application upon clicking an button.
i.e.: if i click button name "gmail" in my app,the data should be cleared of that "gmail" app
doubt:
1.Is it possible?
2.Do we need to be rooted our android device in order to do this?
° because greenify works with root access to force stop the other app flexibly.
I know that greenify works without root but pop that "force stop" ui screen of each single app to do that action.
MY APP FUNCTIONALITY:
I just wanted to develop an android apllication named "anti-theft cloud apps"
simply if an thief stols our mobile then my app detects when he changes the sim or an unique code send by mobile owner through sms from other mobile and logouts all the cloud based applications like gmail,google photos etc to protect our data to be stolen ,so in order to do that i thought of clearing other apps data(like gmail) PROGTAMITICALLY to logout. Is it possible
This is not possible with stock Android. You can do it with superuser, access root/data/data/PACKAGE and clear its content. But as seen in comment, this seems like evil thing.

script to embed in android device?

Scenario: I want to embed a script/executable (whatever) into a Android device to control the camera app, take photos open and close the camera app. I have root access to the device.
Question: Is it possible to do by using python/adb? how can I do that?
If you have root access then you can do that easily as you have full access to your device. Using background services and sometimes broadcast receivers you can achieve the scenario explained in the question.

Android Bluetooth HID connection on paired device

i am trying to realize the following scenario and am failing to do so since about a week.
I have a bluetooth mouse which i'd like to connect to my android phone and use it in an app. The problem is that i don't want to use the built in HID protocol because it has some limitations i don't like (especially swallowing signals when to short and stuff like that). In optimum case i want the app to start, open an inputstream to the already paired and connected BT mouse and add my listeners to it.
Well what i did achieve to do is, given that the device is NOT connected to the built-in android BT Manager, get a BluetoothSocket, connect to it and add my inputstream to it. Problem is: If the user decides to use the OS features to make the connection, my app fails. Also i have to etablish the connection (by clicking the BT-button on the mouse) with every app start. I currently open the connection by using java reflection to call "createRfcommSocket"and then connect if getInputStream().available() fails.
How can i directly read the data of the BT device, without using the HID protocol? It doesn't matter if the mouse-functions still work or not.
If such a thing is not possible, i'd like my app to remeber the pairing process with the app. Meaning: When i start the app, i want my last pairing to reetablish automatically (without pushing the connect-button). Android itself is able to do it (I turn on BT, click on the mouse left-button -> the mouse connects).
I would really, really appreciate every hint you have for as i'm desperate.

Categories

Resources