I have a photo-taking Android app (written in React Native, but I can add native modules if need be) that pairs with a gallery-type app on the user's computer (written in Electron with React). The number of photos can be large (we've had upwards of a thousand photos at a time), and they need to be transferred, uncompressed and uncropped, to the computer app. I need a reliable way to do this without routing the data through the Internet first.
Things I've tried
Node USB: Looks like a good library, but is unusable without installing a driver on the user's computer. The driver then appears to replace the default Windows USB driver, and the phone becomes inaccessible through normal means (opening a file explorer in Windows). Perhaps there's some way to switch drivers "on the fly", using the driver only while transferring photos, and then switching it back out for the system driver once we're done?
ADB: This is the original solution I tried, and it does exactly what I need it to, with two dealbreaking problems: for one, the phone needs to have Dev Mode enabled, and for two, ADB doesn't seem to recognize all devices (we've had a lot of trouble getting it to work with an LG V20, for example). The ideal answer to this question would be something like ADB without those two issues.
WiFi routing: we connect the phone to the same WiFi network as the host computer, use WebSockets to handshake IPs through the Internet, and then initiate a direct connection over the WiFi network. If I cannot find any other solutions, this will likely be the one I'll go for. The biggest problem with this option is the relatively large amount of manual setup required. Our users don't tend to be very technically savvy, and I don't know how reasonable it is to assume they will have WiFi in their home. At any rate, this cannot be the only option for transfer. Further, transferring gigabyte(s) of photos over the wireless network will cause a slowdown for everyone on the same network.
Tether routing: we tether the phone to the computer, and initiate a direct connection much in the same way as in the above step. The downsides to this method are that only phones with SIM cards can activate tethering (not all of our phones have SIM cards, as connectivity isn't their primary purpose for our needs), plus all of the other traffic on the computer will now be routed through the phone, which would be bad for customers' data caps who do have SIM cards. Additionally, there is no way to programmatically turn tethering on, there is only the ability to bring up the tethering menu; it's not too big a dealbreaker, but the other two very much are.
Bluetooth: Generally meets my requirements, but the data transfer rate is far too low, being an order of magnitude below WiFi.
WiFi Direct: I did not actually try this, because I could not find a working way to have the PC accept the WiFi Direct connection. It promises exceptional speeds, but there are no modules or libraries that I've found that would help me enable it.
SD Card: The lowest of the low tech methods, just save everything to the SD card and have the client take the card out and plug it into their computer. Would hands-down go with this, except for the need for a SD card port (guaranteed neither for the client's computer or their phone).
The obvious: manual drag and dropping required files from the phone to the PC. This is how we do things now, and it's fraught with problems. Text files have the last 15-20 characters cut off from them, for some reason, during transfer; many of the photos on the device do not initially show up due to the known issue with MTP not forcing a media rescan on the phone; and users sometimes drop files in the wrong places, leading to unnecessary support calls. This method surely needs to be replaced.
I've been searching for a solution for this problem for two months now, and it's hard to believe that nobody has had a use case for Android like this. It's been made clear that USB communication between Android and PC is non-trivial, I'm sure there are programs that do that, Windows to start off with. Yet try as I might, there are no solutions that work out of the box. Has anyone dealt with an issue like this before? What were your solutions? How would you approach this problem?
When downloading large files on Android it is recommended to use Download Manager, it supports a lot of native features like the progress bar, and notification, also the download task will be handled by OS, and more efficient.
React Native Fetch Blob library support this feature
You dont really need to route the data through the internet.
You can just exchange meta data through the internet:
Extend your desktop app with folder-import functionality (Plug your phone normally via USB, brose to the folder, import).
When you execute this process, let it notify a webservice of some sort (push notifications? Im no phone-app dev.) with which files the desktop-app has imported from which device (ids, filenames, ...) and the phone gets this meta data and can continue its process of whatever it is doing!
Obviously the best solution is a communication channel over USB. Until you figure that one out, you could implement it temporarily this way!
Related
at the moment I'm planning to build an cross-plattform app (iOS/android) that streams music from one device to others without internet. Now I'm considering which network technology is best for this use case. By the way I'm sorry I didn't say hello to you, it disappears all the time.
Existing wifi network:
I don't wanna use this because I want my app to work everywhere.
Wifi-Direct:
Not supported by iOS (tell me if I'm wrong).
Bluetooth:
Here I've found kind of conflicting information.
Bluetooth 2.1 is supported by both iOS and android but iOS has its own protocols and doesn't support the common ones.
Bluetooth Low Energy provides a data rate that is too slow for high quality music streaming (1Mbit) and is supported by iOS but on the android side version 4.3 is required which suspends about half of all users.
What I'm not sure about is the "normal" (not LE) usage of Bluetooth 4.0. Does anyone have experience/information about this?
Creating a wifi hotspot:
This was my first idea and probably it's the best. But there are several issue:
Some carriers do not allow hotspots
It's not possible to create a hotspot without cell reception on the iPhone and some (I don't know which exactly) android devices.
It's not possible to create a hotspot without cellular data activated on an iPhone; I don't know what about android devices (Nexus 4: no problem, SGS3 mini: cellular data can be switched off after creating the hotspot)
-> that's a problem for those who don't have an internet unlimited plan or for those who don't want to share their internet connection (as this dissipates the high speed volume) but see the next point for that.
In order that everyone can use his own cellular data connection the wifi settings can be manually edited on iOS (remove router, DNS and search domains entries). Is there a way to do so on android as well? Is there way to automize this process?
https://apple.stackexchange.com/questions/173894/can-i-connect-to-wifi-but-still-use-cellular
Is there any way to create a wifi network programmatically (not just enable the normal wifi hotspot)?
SDKs/Frameworks like Open Garden or Alljyon looked promising at the beginning but:
Firechat (which is made by the Open Garden team) promises that iOS and android devices can chat locally without existing network but actually it didn't work for me with an iPhone 6 and SGS3 mini. However they don't want to publish their SDK. The only information I got is that it works over wifi-direct and bluetooth. If anyone has an idea how this could work, please tell me.
Alljoyn does not provide direct communications between iOS and android without an existing network. (Tell me if I'm wrong)
API's:
iOS multipeer connectivity does not support android
I hope anyone can help me.
Regards Nils
If you are talking about a TVBOX device with Android, you will need the ethernet cable connected in order to create a hotspot.
Another option that I have done is:
Create a service that runs on iPhone with an interfaz, do whatever you want on that interfaz, then send what ever you need to a webservice, then in Android, just pull that info from another App as a service, or just store it in an internal sqlite.
Good luck
Is it possible to simulate a USB or Bluetooth device connected to Android?
I would like to make an app which is able to simulate an HID device locally. What I mean by this is: the app should make Android believe that an USB/Bluetooth HID device is connected. This would allow my app to inject touch events globally, I hope. Is there anyway to simulate a (virtual) device? Note that I don't really care about the device, I just want to use the built-in support for HID input.
I know a lot of people already asked about touch event injections but this approach seems to be a little bit different. I do not want to use this for testing purpose, so InstrumentationTestCase and the like won't help.
Rooting the device might be an option, although I can also imagine to ask my endusers to install a specifically signed app manually (according to https://stackoverflow.com/a/16737083/2923406 and https://stackoverflow.com/a/22902808/2923406 this works, but it would be device specific).
I am aware of:
Simulate a mouse input on android - This guy seems to do it in his own app, although his questions wasn't answered ;)
http://www.pocketmagic.net/2013/01/programmatically-injecting-events-on-android-part-2/#.U58SqfldVHV - Needs Root. Did anyone succeeded in using this? Also, the solution seems very device-specific again.
Bluetooth + simulating mouse - That's not what I want. The phone itself should not be an HID device, but use the (virtually created) one itself. Same for this:
https://stackoverflow.com/a/8174973/2923406
Note that I do not want to turn my phone into an HID device of any kind.
Simulating is a broad term. When I created my Bluetooth app I "simulated" a Bluetooth connection in two ways.
Way 1: Use a serial port UART converter and hook it up to a Bluetooth module transmitter.
Then you can use a terminal program like CoolTerm, to send your data.
Like so. In this case I coded in a string to send on successful connection with the device however you can make a infinite loop for testing purposes effectively not requiring your phone to be turned into a HID device.
Way 2 (not easy): Use your computers bluetooth in a server/client relashionship model.
This is harder to do. What you can do is convert your pc/mac into a server and the Android phone into a client or vice-versa. For this you will need to write external code which will need to be compiled separately on a jvm(java virtual machine). The procedure to do this can be found here. If you are using a Linux machine you have to separately download the Bluez module. I have not tried this on any other operating sytem other than Ubuntu, and it was a pain to get functional.
Hopefully that helped.
Yes, it's quite easy using the AOA2 protocol check this & this links for details ( you'll need to switch your device to the Accessory mode )
This may be possible (or at least be easier) using the Robolectric library, which simulates a full Android device locally. Although it is intended primarily for testing, the fact that it simulates a whole device locally - including Bluetooth and USB - means adding to it may be an easier approach.
In other words, you may be able to modify the classes it uses to simulate these abilities locally (i.e. in the IDE itself without an emulator or device) in order to simulate them on the device itself. After all, it does provide full simulations of these functions. You could simply change these Bluetooth and USB simulating classes to load onto the device itself rather than onto the local Robolectric test "device."
This is just an idea though - I can't confirm this will work - it just might be a good place for you to start.
Every now and then, the radio of my android phone silently dies because of some network related issues.
On the Nexus 4, it shows the empty triangle as if there where no service available in this area. On other phones it does not even do that. It looks like signal is fine.
Anyway, after the radio died silently no phone call / text message / data is going through in any direction.
The only hint I get from the System is the android.net.conn.CONNECTIVITY_CHANGE broadcast fired when the signal dies and wifi is not connected.
The only thing, that fixes the problem is restarting the phone.
Finally my question:
Does anybody know how to restart the radio completely by code?
I mean, it is a separate image running on a separate CPU. There must be a way to reboot it without rebooting the phone.
Maybe there is something, I can path into the Android ROM. I'm running CM here and be happy to patch it (again).
I tried fixing it by launching a system app by pressing *#*#4636#*#* on the dailer and stopping the radio and starting it again. But it did not help at all.
I recently made an app that checks the radio every time the connection changes. It shows a simple notification that tells me, I should reboot my phone. [1]
Issues reproduced on:
LG Nexus 4
Samsung ACE 2
multiple Apple iPhone 4*
Issues not reproduced on:
Apple iPhone 5
All phones running in the Dialog.lk network.
[1] https://github.com/felixb/network-checker
On a rooted device, one can issue the pkill command for all processes running as the user radio. I tested this on a Oneplus 3. The system seems to immediately restart the service:
pkill -u radio
Yes it is possible, but it will be difficult to perform on device without a deep understanding of the modem communications code of which multiple versions exist and even that will be dependent on if the system will permit you to even perform the communications on device.
The only one I am aware of that you can fully manipulate on device at this time is Qualcomm's (Qualcomm is standard in the majority of devices, but Samsung has used VIA in some cases which is a whole different monster, and even still another chipset or two exist), but to even be able to perform what your asking with Qualcomm's chipset, the following must be true:
The device must be rooted.
The application must have root access.
The system ROM must have the ability to place the cellular radio into modem diagnostics mode.
The device must have the appropriate permissions to permit the access.
At this point most people would connect their computer to their device and manipulate the cellular radio using QPST, CDMAWare, or QXDM. Options available to those users include everything from manipulating cellular subscriber data to restarting the cellular modem.
But, this is where things get tricky, you need to be be able to access this from the device side, which depending on the device, the operating system, and the configuration of it...may very well not be possible.
Also your application must be able to communicate with the cellular radio using the special protocol that the applications above use to do their communications which will require you becoming intimately familiar with that specification. The whitepaper for the Qualcomm diagnostics protocol is floating around on the web if you look hard enough for it.
Also on the not so cool side, if your application has access to the radio...so does any other rooted application (or even non-rooted, if you don't set the device permissions correctly) thus enabling rouge applications the ability to change your radio's configuration data potentially even bricking your device (which I have seen people do using the applications named above).
So my answer is Yes, you can do it, although:
Depending on your device you may not be able to, you should be well prepared to study and develop the needed tools to perform what you are wanting to do
No quick-start guide exist to be followed
Remember that you do so in the knowledge that your device could potentially be bricked either by a mistake in your coding or by a rouge application.
Rebooting the radio, as you have done in the device menus, may not help your problem, you may still require a device reboot
My advice is to use a much easier method and include a timer with automatic reboot in your current application, it is much safer, won't brick your device, and you won't have to become a cellular engineer to figure out how to accomplish it.
Your timer could begin counting down when the radio dies, and provide you an option to stop the reboot if your doing something important, otherwise it would restart your device and all would be ready when you reached for it to make a call or check your email.
Hopefully I was able to help, even though I know this is not the answer that you wanted.
Side note, if you could hijack Android's system configuration menus from an outside application you could potentially manipulate the radio state using the same methods used in Android...but you already discovered that restarting the radio in this method does not help your situation. Plus Android is designed to prevent such manipulation to prevent malicious applications from overtaking the UI of other apps and the system.
I need to create an application that control PC mouse(pointer) through android device without downloading a server on pc, it should be able to communicate directly with my pc I already checked out the remote droid application but the user would need to download a client server to communicate with the phone
so is there way to remote control pc mouse through phone without downloading a client server on pc?
note: I am working on android 2.3.3 thus i cant use wifi direct and usb accessor
Why not just simulate regular bluetooth mouse, a standard bluetooth mouse which has its drivers as part of most os's.
no one can control your pc remotely without bluetooth pairing.
in theory i think it should be possible, but it requires knowledge in hardware and low level software (so its not a task suitable for most developers).
It doesn't matter what the client is, the fundamental question is "Can you move the mouse cursor on your PC from anywhere without installing software"
The short answer is no - which is a good thing! Otherwise, anyone on your network could just take control of your PC...
That said, you could, in theory, create an RDP (Remote Desktop) connection and use that to control the PC as a whole - but that is very complex, has been done already and would still require the user to allow remote desktop connections to the computer (Control Panel->System->Advanced->Remote)
Edit - Bare minimum app:
There are a number of ways to approach this but the absolute simplest app I can envision involves having an application on the PC listen for connections on a TCP/IP port. You'd then send messages to this port from Android using the Sockets classes.
The app would receive these messages, parse them and perform the appropriate mouse actions.
Make sure that you include an authentication/authorisation mechanism - you don't want random strangers to be able to control your PC just because they broke your wifi.
You may find it easier to build the desktop app to accept messages using the HTTP protocol (RFC) - This is a standard, widely used and very flexible mechanism for client-server communication. Why reinvent the wheel? This would also make your Android-side code far simpler as you could use HttpURLConnection and other similar classes which abstract the complexity of managing sockets.
You may also want to consider if the app should provide any feedback to the client - eg the new mouse position or a success/failure.
NB: Running the app as a windows service or website might seem preferable to a desktop app (doesn't need to be started by the user, nothing in taskbar/system tray) but there are considerable drawbacks to both - Windows services can't interract with the desktop easily (what happens if nobody is logged in?) and websites run as a different user so in addition to not having the same desktop, they have limited permissions.
It might be a case that i misunderstood the point. I think however that you can play with the BT protocols. If you find a way to recognize the phone form the pc like a BT mouse you can control the pointer. I think some of the low end SonyEriksson phones had that option build in.(SE880i).
Though I am not sure how the driver problem will be solved.
Regards
TT
If it is possible to plug into PC's USB Then
Arduino mouse using a cheap Arduino board
https://www.arduino.cc/reference/en/language/functions/usb/mouse/
Arduino wifi or bluetooth using same or another board (or connect by Serial, UART, SPI, I2C cable).
software on cell phone (Android) to connect to wifi/bluetooth
Some hacking at the C level.
Notes
- no driver on the PC
- Could do the same with PIC32 (even with
PIC8/16 but might take longer).
This is a typical real world IoT type project.
As a project it is between 40 and 160 hours to demo prototype for an experienced consultant. Parts cost estimate under $400 besides cell phone cost.
120 to 500 hours for 20 production prototypes + layout and assembly cost about $4000.
Production target unit cost under $25.
In other words a neat Kickstarter project.
Experienced soft/hardware & lucky hacker could do it 24 to 36 hours.
In Micromax q2+ Iam able to access the bluetooth - remote control and after pairing be able to move the mouse to my pc. One thing is am unable to do any action events.
I'm trying to figure out how to transfer frames rendered on a computer to an android phone. Wifi and Bluetooth aren't fast enough for a smooth framerate, but the data transfer speed across the USB connector is more than enough (up to 480 megabytes/ second). Thing is, I can't figure out how to do it- there's nothing in the Android docs and I haven't found anything online. How can I access the USB connection?
You can't access the USB connection in any documented and supported fashion.
It's not possible at all? Are there any hacks that allow it?
It's not an app for publication, and I don't mind messing with my own phone.
Try turning debug mode on and using adb to connect to the device. You can manually push files to the phone (e.g. to the sdcard) which you can in turn periodically check in your app. You can also write files the other way around (from your app) and have your PC app check that file, again over ADB. That way you can establish simple protocols for communication.
I also need this right now, but a bit more difficult since I try to access the phone from an programmable integrated device with USB host chip inside. Which probably means reverse engineering ADB...
Either way, it's a pretty hacky solution but it should work over all phones as long as debug mode is turned on, which makes it feasible.