Search code examples
c#androididewindowusb

Obtaining file between Android Phone and Window App


I'm beginner of Android Phone programming and looking to this project as learning curve to implement this solution. I'm experienced in embedded C, C# and Winform under VS2015. I have done USB based project under VCOM (CDC).

The setup is

(1) Android Phone, possibly Android 6 or 7. Low cost phone ($100).

(2) Android Phone App (of which I need to be create) generate CSV or XML file in a specified folder or data array. This CVS/XML contains timestamp based on UTC and logs other informations.

(3) When android phone plugged to Window (8/10), the C# based code (VS2015) in Window detected the phone and download the CSV file.

(4) It also reset the time/date between laptop and android phone to keep it sync to mSec (how to block timestamp reset by Android Phone due to GSM/WiFi).

(5) Alternatively I can keep seperate timestamp that is ticked by Anrdoid Phone OS (every 1mSec)

I have VS2015 C# app in winform (old fashion), with USB interface on VCOM (and FTDI Driver) as well as auto detection when USB device plugged in. What kind of interface the Andorid Phone make when plugged in.

(a) It there simple way for VCOM to work between them without installing driver.

(b) Is there way for other interface that work on USB that window app make connection to them (was that HID?). What do I need to make this work?

(c) Is there demo project or code kit to do this or website link?

(d) Would it be possible to C# code on Android Phone, it would have simple graphical user interface of few buttons. If so what the best (low cost) IDE package to do this?

The alternative to USB connection is to make it work on WiFi or Bluetooth or GSM between Laptop and Android Phone but that would be a seperate project.


Solution

  • As per your requirement, I have few suggestion which you can utilize to perform your task.

    1. Use Xamrine Studio for building Android apps in C#. One of the main thing is it is free :). Few of the samples you can get from link https://developer.xamarin.com/samples/android/all
    2. Now you can build your android app which can generate csv or xml in C#.
    3. You can create another C# code for Windows OS which will detect android device when it is plugged in. YOu can find sample code in below link. How to know when Android device is plugged into USB port?

    Code provided is a simple example, you have to update it as per your need. 4. Now from this app you can get xml which you might save at some predefined standard location in your android phone.

    Apart from creating socket via Wifi connection or other connection, you can also upload your files to google driver/dropbox from mobile device. After that you can get that files from your desktop application.