Connecting android app with application on a pc - android

I am currently trying to write an android App that is connected to a application running on a pc (even though windows is preferred linux would be ok, too) via either USB or Bluetooth. Right now I'm not really sure how far this is possible. As far as I understand the USB Android API, I can not really use USB to talk to another application. Only raw file exchange seems to be possible. The Bluetooth idea seems a lot more feasible as I see it. I'd write a bluetooth server for the PC and connect to it via a Bluetooth client written via Android API. Point is, is that possible with windows? Has anyone seen any examples for what I am looking for? All I can find for USB is teethering which is not what I want.

There are android applications which allow you to use your mobile's touchscreen act like a touch pad which can be used to control your pc or laptop via bluetooth or wifi connection just like you are using your laptop's touch pad. PremoteDroid, RemoteDroid, Gmote etc.. to name a few (or only these are available i guess!).
But to do so you also need to develop a server application which will run on the device you wish to control and help u make connection between your mobile and the device. I have used PremoteDroid and RemoteDroid and they both work well on my laptop which runs windows 7. You can even add keyboard functionality.
PremoteDroid is openly available here: http://code.google.com/p/premotedroid/

I have a Bluetooth server application on my Mac that I use to test an Android app I'm writing. The app will eventually be used to communicate with a device with a microcontroller and bluetooth modem, but I needed a way to test the app in the absence of that device. The server app is written in Java, so I think it should work on a PC (and almost certainly in Linux).
I'm happy to share the code with you--I found it somewhere on the Internet (though I can't seem to figure out where now) and modified it as I needed to. It uses the BlueCove library, and is only about 60 lines, including several imports (and the code I commented out but didn't bother deleting :). I also have a Bluetooth client program on my Mac, since my app also has server functionality.
I have never tried to do anything like this using USB.

Related

How to perform mobile app packet analysis?

I've written a an app and I'm having issues finding a solution to tcpdump data from the Android device running said app.
Android:
The only solution I've found is to root your phone (https://code.tutsplus.com/tutorials/analyzing-android-network-traffic--mobile-10663). Although this is not always possible. There needs to be a way to perform analysis via adb or Android Studio. Unfortunately I have not found a way to do that.
Additionally I've tried PCAPdroid which is an app. This does not seem to be giving me all of the packets I expect to see.
iOS:
Apple provides a feasible solution to create a virtual interface with a connected device where you can then tcpdump all traffic leaving said device.
https://developer.apple.com/documentation/network/recording_a_packet_trace?language=objc

Simulate USB/Bluetooth HID device locally in order to inject events?

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.

Android app that sends and receives data from pc

So ill do my best to explain. I'm wondering how easy (or hard) it would be to make an android app that talks/sends and receives data from a PC or mac, even more so with flash.
so for example, I first make a flash application on my PC / Mac, lets say it has a MovieClip of a square on the stage. That is all for that part. Next I make and android app that consists of one button. when I press that button (on the android app, on the phone) the square on the flash desktop application moves to the right or left by ten pixels.
so ultimately the mobile app is controlling the desktop flash application.
Iv searched and searched but I'm unsure of what keywords to really use to find what im looking for.
Can anybody shed some light on how difficult this is(if its possible), or any documentation / tutorials on this subject?
The Bluetooth standard includes a profile called Bluetooth HID. If you write (or download!) an Android app that implements this profile, then connect your Android device to your PC, it basically becomes a Bluetooth mouse or keyboard. It would require no programming on the PC side, as both Windows and Mac support Bluetooth peripherals.
Implementing a network protocol on the device side is usually really low-level stuff. If your programming experience is only in flash, you'll probably find this tough going (you would likely learn a lot!). Luckily, there's the Android HID library. I don't know how good it is (I just found it for this answer), but it looks done, so it would save you from having to do the most difficult parts.
You can use adb to accomplish this, which is how many of the tethering apps get around carrier restrictions. Here are some sources:
Adblib is a "library to communicate with android devices with TCP over USB without requiring the Android SDK":
http://code.google.com/p/adblib/
Thread about Adb over USB:
http://groups.google.com/forum/?fromgroups=#!topic/android-developers/JsDTBimHpOA
adb itself:
http://developer.android.com/tools/help/adb.html
Here are some other links to some other Android USB topics:
http://developer.android.com/tools/adk/index.html
http://developer.android.com/guide/topics/connectivity/usb/host.html
http://developer.android.com/guide/topics/connectivity/usb/accessory.html
http://developer.android.com/reference/android/hardware/usb/UsbInterface.html
http://developer.android.com/sdk/win-usb.html

how to control pc mouse from android device without client server

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.

Android mobile as a GSM modem?

Is it possible to use an Android mobile device as a GSM modem?
I have been working with GSM modems for several years. I am developing apps under .net to make data calls, send/reieve SMSs and so on, i used normal GSM modems so far, not mobiles.
Now I'd like to connect some android devices via USB to my PC and use it as a GSM modem, communicate with it via standard AT commands.
Is there any kind of driver/app/etc to handle it? It would be nice to communicate with it via RS232.
Thanks!
Environment: Windows XP/Windows 7
Mobile to test: Sony Ericsson Xperia Mini
I honestly don't know a straight answer to your question, but I would recommend perusing the docs on USB to see what data/info you can transfer.
http://developer.android.com/reference/android/hardware/usb/package-summary.html
With what you're wanting, though, you'd also need to develop your own desktop app. You may be able to use ADB/shell to communicate. Phones may also need to be rooted for it, depending on how much control you want.
Drivers required would be the device manufacturer's USB drivers, if any were needed (which they are for ADB/Shell).
I have found very helpful what I want in my application. Following android application today I have found and worked for me.
It gives the two APIs through JSON. First for sending SMS and second for receiving SMS in my Server side programming language.
https://play.google.com/store/apps/details?id=com.gsmmodem

Categories

Resources