Possible to Run a Java GUI on a computer from an Android? - java

If an Android device were connected to a computer via USB charger, would it be possible to launch a java GUI on the computer from the device (i.e. by pressing a button in an android app)?
Also, would this be a platform dependency nightmare?

Possible yes, not easy though and there may be some platform issues.
You would already need to have something running on the destination computer which detected the message from Android and then launched the GUI.
In fact the simplest way to do that may be to ignore the USB and just do the whole thing over the network.
You can't just run arbitrary code on the computer by plugging the phone in though, if you think about it that would be a massive security hole!

Related

How can I disable and enable a USB OTG connection to power a hardware device on and off?

I am working on an android project where I use a phone to power an external device. Through a USB-OTG connection, I can power the external device.
I want to know if I can write a program on android studio where I can press a button in the app to toggle the power to this external device (turn it on and off).
I've seen it done before on an older Samsung Galaxy 3 phone (on a much older version of android) by updating data in a file; specifically this file:
/sys/devices/virtual/host_notify/usb_otg/mode
But I'm trying to write the software so it is more generic and can work on any new android device.
Is there a way to do what I need?
I've tried finding a generic way to do this but it doesn't seem possible because the only way I've seen it possible is by using shell commands to toggle exposed kernel bits through root files.
I have concluded it's likely impossible to make generic code for this as most android phones root files are organised differently. So you need to discover the specific file each time you want to use a different phone for the software.
I don't think it would be feasible for myself to create a database of different brands of phones root file structures because new phones come out all the time with new structures which would require too much maintenance on my behalf.

Success in using Android to control an external monitor via HDMI

just wondering if anyone has managed physically to use an Android tablet to control an external screen via and HDMI cable. The Android tablet should have the Presentation APIs, so a version > 4.2m and an HDMI (or mini HDMI) port.
https://developer.android.com/reference/android/app/Presentation.html
So far we have tested with a tablet that has Android v5.1.1 and a mini HDMI port, but as soon as we connect the external monitor, the tablet monitor shuts off (but it is still responsive to touch) and all the output goes to the external monitor.
The tablet is a HannsPad Titan2 13.3 inches.
So we are still stuck on the physical setup. It this does not work at least with mirroring, how can we be expected to start tinkering with the presentation API?
So we are looking for confirmation from other coders that the setup is at least physically been done and tested at least once..
Thanks
W
as soon as we connect the external monitor, the tablet monitor shuts off (but it is still responsive to touch) and all the output goes to the external monitor
That was an incompatible and unfortunate choice made by your device manufacturer. The screen should remain on. You might rummage through Settings to see if there is a way to configure this behavior, or contact the device manufacturer for support.
The tablet is a HannsPad Titan2 13.3 inches.
Buy a better brand next time.
It this does not work at least with mirroring, how can we be expected to start tinkering with the presentation API?
Buy a different tablet. Note that (micro-)HDMI connectors seem to be less common, though some tablets might also support MHL or SlimPort.
Or, in Settings > Developer options, choose "Simulate secondary display" to give yourself a floating window that serves as a fake external display that Presentation can drive (except perhaps on Android O). For development purposes, this works for light testing.
So we are looking for confirmation from other coders that the setup is at least physically been done and tested at least once.
I have never used that tablet. However, the Presentation APIs work just fine. For example, I was just updating my CWAC-Presentation library yesterday, and part of that testing included trying my demo app on a Nexus 10 connected to a micro-projector via its micro-HDMI connector.

Sending data via bluetooth between Android phone and laptop running OS X

It seems like a relatively mundane task to make an app that can send data via bluetooth but I've been banging my head on this for the past few days so I'm looking for any ideas. I'm running OS X 10.10 and using a Nexus 5 Android device. Here's what I've tried so far:
I need a server program running on my laptop and I need a client-side android app running on my phone. However, (correct me if I'm wrong) the server program running on my computer needs to be able to access the Android Bluetooth API because I need to use the BluetoothServerSocket (based on the server-side code provided in Google's Android Bluetooth tutorial).
Since it's server-side code, I need to run it on a server so I built a Java Servlet which I ran from inside Eclipse but I didn't know how to access the Android API from inside a dynamic web application.
So I started following this approach where the Bluecove library made that possible: http://luugiathuy.com/2011/02/android-java-bluetooth/
I tried getting Bluecove to work with OS X but there are a whole host of issues involved with that. I found some workarounds and then got an error dealing with the IOBluetoothLocalDeviceReadSupportedFeatures device that Apple removed in its later OS versions (but Bluecove depended on it).
I found a fix here that installed the old IOBluetooth library and changed the DYLD_LIBRARY_PATH to point to it. Unfortunately, this had no effect (I don't know if I changed the library path properly...I followed the instructions from Solution 1 in the answer from this post).
In any event, I feel like I'm overcomplicating this task and am looking for any guidance - in terms of overall approach or a specific thing I missed. The primary issue is accessing the Android Bluetooth API inside the server program intended to run on my laptop.
I eventually ended up using WiFi to send data since there was better software support for that.
But if someone wants to pursue the Bluetooth path, one possibility is to run OS X Lion (which had the IOBluetooth library) as a VM and run the server-side Bluecove code on the VM. This would require a separate Bluetooth USB dongle to be attached because the VM can't access the bluetooth hardware of its host machine - there may be a way but by default it can't access the in-built bluetooth hardware.
Not an ideal solution but I don't know if there is much choice until Bluecove releases a version that is supported on recent OS versions.

JavaSound: Detect device change

Folks,
I am working on an applet that captures audio from the local computer and streams it up to the server. I am using a Java applet that currently hooks onto the default device and performs the upstream. Things are running well.
I now want to extend the functionality to allow users to choose the audio input device and to also show a sound level indicator of the chosen device in the web page.
I wrote a multithreaded utility that would do AudioSystem.getMixerInfo(); periodically and look for changes. There is also a thread that reads from the chosen device and displays sound levels.
My problem is that when I run my code and plug in a USB headset, the new device is not detected. However, if I shut down my code, then plug in the USB, the device does show up.
Is this a known and documented limitation of JavaSound that it does not sample the device set once the process is running?
I am using OSX Lion.
Thanks for any insights.
-Raj

Control a desktop application using an android phone

I want to build an application where an android phone would control a desktop application.
I only need to send coordinates from the phone to the desktop when user's finger is on the phone screen.
But I am kinda confused on the networking side if i should use bluetooth, usb, or wifi (intranet).
I did some research on bluetooth, doing bluetooth socket programming on an android phone shouldn't be a problem, but on the desktop side there are only a few free SDK/library. any suggestion on what to use?
If I were to use USB/cable, What API on the android side I need to use?
I am actually more familiar with general socket programming (wifi), but I think it's going to be slow (correct me if Im wrong) so this would be my last option.
PS: I am using Java for the desktop application too
any suggestions on what method to use? or even maybe I should use .net on the desktop side?
Thanks
You might find the open source RemoteDroid app to be useful in creating your app. It may even do everything that you want.
The source code is here. You may need an svn client like TortoiseSVN in order to download it.
Wifi is probably the most supportable.
Bluetooth requires hardware and drivers on the PC side
USB would ordinarily seem like the most sensible if the wire isn't a problem, but the catch is that it requires that the user enable "USB debugging" on the phone, and have either the android SDK or equivalent functionality to the adb forward command installed, plus a compatible USB driver for the phone. If all that were the case, you'd just forward a port from the PC to the phone and have a pc program connect to that port on the loopback interface which will be forwarded to a service running on the phone.
It's possible you could do something piggybacked on the USB tethering capability of more recent releases to get you a network-over-usb that you could use to connect programs on the PC and phone, but you'd need modified PC drivers so that you don't actually push the PC's internet traffic through the phone (unless you mean to tether as well).

Categories

Resources