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.
Related
I have been searching the net for some sort of explantation on how I would get started on coding this but I haven't found anything. I know about ports and streams and basic networking stuff in java but I just can't seem to find any resources describing how this can be translating to android. I looked through the android api (https://developer.android.com/training/connect-devices-wirelessly/) but I actually don't understand any of what is written on there.
Back to the question though. The app would simply do this basic function:
two or more people connected to the same network open the app
when opened , the app automatically scans for all the phones connected to the same network that have this app open
the app would then display the name of each phone with that app open connected to the same network on the screen(in activity main) as a simple array (the name of the phone would just be the bluetooth name a guess)
This might be too complex of a question to answer so If there are any resources such as videos, api, etc. , that describe this process that would be great
NsdManager will fulfill all your requirement. You have to first register the service on the network through NsdManager using IP and port. Then Discover and resolve that service from another end.
https://developer.android.com/reference/android/net/nsd/NsdManager
https://android.googlesource.com/platform/development/+/master/samples/training/NsdChat/src/com/example/android/nsdchat/NsdHelper.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.
Hi guys could any one help me a little bit, I'm making an android app, for cabs request, but I need a way to send to the driver app, an alert where he accepts the invitation to pick up the client, if he choose the accept button, and alert pops up on the client app telling him that the driver is on the way :) Thanks, I think i need for Threads to me always watching for these client notifications.
You can use Socket programming. This is an example where it shows how to communicate between two android phones.Example shown in emulators
http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/
This question depends on a few factors. Whether there is a server to control the communication mechanism or not. Whether the devices are close to each other. Whether there is a network oriented method like SMS allowed to be placed and so on. To minimally answer this, the following could be the easiest way to communicate between two Android devices.
If the devices are close to each other, use Bluetooth
If the devices have a server to connect in between, use an Android service to take the connections things to the background
If there is an SMS/Call based connection between the devices, use Intents and Content providers to further deal with the data.
I want to make an app where it allows the user to give remote access to viewing their phone (first-person view of user using the phone). Kind of like how tech support can sometimes see what you're doing on your computer to help you with problems. Think "remote desktop for phone" is what I'd like to do.
Does anyone know if this would be possible?
My current idea to do this is screen scraping - somehow take a screenshot of the user's phone (like how DDMS does) every millisecond or something. This seems terribly inefficient though, and again I don't know if it's possible.
Note - the "receiver" of this first-person phone view can be a computer or website or whatever, along as they connect remotely.
It would be possible: extremely difficult, but possible, to implement an Android activity that uses a FrameLayout and hosts another Activity. You could then fetch the image buffer of the FrameLayout as shown here and you'd then have to feed that into a video encoder and stream the output of the encoder to a remote server, but that might work.
I actually wanted to create something like that as well...
First of all, it will only work on rooted devices, since access to the "screenshot" (framebuffer) is allowed only to rooted devices.
Now as to reading events from the controlling device - that's easy... The hard part would be to generate these events on the controlled device. But I'm absolutely sure it's possible for rooted devices, as I saw some similar program for Windows which controls the connected device (can't remember its name).
Anyway, the reason I stopped thinking about this app is its complexity and the fact only Rooted devices could be controlled.
Hope this helps
To check if a 'switch' is open or closed and detecting that in Java, I have the following plan: I won't use the data pins, just the USB 5V current, and if the switch is closed there is a current, which I should detect in Java, and so it will be processed by my program.
Would there be a simple solution for this or do I need to find and try out a whole Java usb library for it, of which I would use just a tiny little bit?
Thanks in advance
This will not work in the way you describe it. Have you ever connected a gadget like USB lamp or USB fan? Then you would know that the Software/OS does not even know about them.
The USB spec says you can draw up to 100mA from a port without telling anyone about it, and 500mA when declared in the USB protocol. Most USB HDDs draw quite some more than the allowed 500mA maximum USB2 current.
To make your application work, you absolutely need a device which can talk over USB. This could be an USB=>RS232 adapter (which your application can talk to using RXTX) or a HID device like a USB Joystick. Joysticks can have buttons and switches.
You could try RXTX. This is a library written for serial communication with Java. http://users.frii.com/jarvi/rxtx/. You will have to use native libraries, and I don't know if it would be able to detect if there is a current or not on the USB.