I have an program on PC that sorts and organizes various types of files into a database and does some stuff with this data. It's a hassle to add photos though (Take photo, load to Google drive, download on PC, add to program) so I'd like to have an app that takes a picture and queues it to be added to the database next time the phone is connected to the desktop.
I can't figure out a way to access my phones root folders in Java though since I can't assign a drive letter to it. I've done some research, and it doesn't appear that my phone (Nexus 4) has that capability without some rooting or modding. Is there any way I can use java to detect when the phone is connected and access root folders?
I know the other option is via a network connection between the two devices, but I have 0 networking knowledge so it seems a bit audacious at this point to attempt that.
Thanks
While not exactly what you're asking for, since it doesn't do it when you plug the phone into the desktop, take a look at PushBullet, you can use it to send anything from your phone to your computer (or any other device for that matter) and viceversa.
Related
I wrote some classes for my Android-program and it runs. However it takes too much ram because the data in the File is not in a nice form to be processed by the application. Let's call the File Foo.txt for now.
I now want to save the data from Foo.txt in a different form which lets my Android specific code (specific in the sense that it uses Activities, Context etc) do easily since I have all the code for it already, and then load from this data manipulatedFooFile.txt instead. Problem is, I don't know if it's possible at all to save to a file which I can then later retrieve on the desktop, either in an emulator or via a device connected to an USB or a way I don't know of yet. This way I can replace Foo.txt with manipulatedFooFile.txt which would let me use less ram and space on disk.
I know that one other solution would be to remove the code from android and put it into a normal java program. Put that would take a bit of struggle since I have to remove all the dependencies on code that is not there, or start with nothing and write big parts of the code again.
Files and folders can be sent to and from your android device using adb (or android debug bridge).
Using the adb pull command under the syntax adb pull <remote> <local> you are able to transfer a file from the filesystem of the connected android device to your local device (your computer).
From the official documentation for adb pull:
Copies a specified file from an emulator/device instance to your development computer.
Similarly, adb push allows you to push a file from your local computer to the target emulator/android device under the syntax adb push <local> <remote>.
I have very old Siemens CX70 in working state and just don't want to throw it out. My idea is to use its math power and peripherals (GSM module, USB, Camera and screen) to build some simple applications for home use (multichannel termometer, timer and cheap security system - for examples).
I know I should use Java ME and IDE (I love Netbeans, for example). Can you tell me what I need more to start developing? I know Java well, I just need to make an environment to developing, debug and deploy. Mobile library documentation will be very helpful too.
Thanks.
There are so many online tutorials about this topic that the only right thing to do is to refer you to google.com
Search after "getting started with j2me".
However, there's something else you should know upfront before getting too excited.
The security model in JavaME will prevent you from doing much useful stuff, in relation to some of the things you mention.
Every time you try to access certain things in the phone, like e.g. the camera, or send SMS, or read/write a file on SD card, etc etc - the phone will show a popup "This app is trying to access camera. Allow this?". And the app will only continue after a manual click on Yes.
As you can imagine, this of course renders a lot of ideas useless.
In order to prevent these popups, you can sign your app with a certificate you buy from Thawte or Verisign. But as that'll cost you $300 a year, it's not the way most sparetime hobby developers chooses.
Personally, I found another way, but it requires you to use a phone from Sony Ericsson.
Because the old Sony Ericsson phones can be patched in order to remove the Java security. After doing this on one of my old phones, I've been having fun making apps like the ones you mention. For example, an app that keeps an eye on my home when we're out, by taking a picture every second. If it detects a difference in the picture, it sends me an MMS with the picture. :-)
I have searched a long time for patching options for other brands, but I just can't find anything useful. Nokia should supposedly also be patchable, but I just can't find anything useful about it.
So in short: If you'd like to make some sparetime hobby apps on a phone like that, you should either find a Sony Ericsson phone and patch it - or go dig up an old used Android device.
Good luck.
I am writing an application that will allow an android phone and java application on the computer to communicate over the USB cable. Using Bluetooth or Wifi is not an option in this case.
I found it very difficult to find a nice solution to this problem, and the Host/Accessory libariries seemed designed to hook the phone up to docks/cameras/circuitboards rather than simply a PC. This is my solution, let me know if there are better alternatives:
I'm going to create a Java application to use ADB to push files onto the phone, the phone will then check those files for changes and act accordingly.
It seems to work well so far, except I am using the /sdcard/ folder to hold these files. I want this app to work on phones without SD cards too, so I want to know if there is some other safe folder that I can count on being able to access from the PC with ADB and the android app as well.
(I have looked at INTERNAL STORAGE libraries, but I don't know where they store their data and if I can push/pull with them from ADB.)
Thanks in advance for any help!
Read this https://groups.google.com/forum/?fromgroups#!topic/android-developers/tZrxqZQLh98
Nice discussion about holding tmp files.
Do u want to control your application from PC? Cant you use Intents launched by ADB for that?
Another options port forwarding over USB with ADB:
adb forward tcp:6100 tcp:7100
adb forward tcp:6100 local:logd
Personally I end-up doing GET requests to my local Apache server to fetch data.
Or on rooted device many folders become available.
I'm pretty new to android so apologies if I'm missing an obvious solution, I'm developing an android app that would be used to record various data including photographs and hopefully the intention would be for this collected data to be uploaded to a desktop application where certain desktop specific jobs could be carried out.
Due to the fact I intend to save photographs within the app in the SQLite database as a bytearray which recorded information would be I think that it would be too data intensive to send to a server, plus I wouldn't want the desktop app to necessarily be on a server, it should be standalone. I'd prefer to use the USB connection and allow a USB upload of the data from the app sqlite db direct to the database on the pc, probably sql server. What would be the best way to approach this? Could the android ADB be used to acheive this?
Any help or suggestions on this would be much appreciated.
Regards
I believe that your sqllite database (as well as photos contained there) will be stored on the SD card of the device. You have to options here, first, when your desktop applications find the folder on the device SD card (should be mounted on the filesystem after connecting the device to your PC), second is to use bluetooth and initialize the transfer from the device to your desktop application.
You could try having them on the same network and having them interact that way. I know applications such as RemoteDroid do this, but I have no experience doing so myself. There is also the fact that there is the data saved on the sd card / by putting your device in Storage mode and you could just point your desktop to the device drive and assume a designated folder your app uses exists.
Adding on to the answers here, you could save your photos as files in your sd card and transfer it to your pc from there.
Here is a dev guide on storing files.
Another way is to transfer over WiFi. Ice cream sandwich seems to have a WiFi Direct api that allows us to perform P2P transfers over WiFi. I have not used it yet but have a look at this
Solution 1
I would probably use rsync between my desktop and android. This way you can export data from your sqlite to a flat file and import it to your local database on your desktop. This way you can also put your schema into a file.
RSync is a very stable protocol to exchange files.
Solution 2
You can also use Amazon S3 for this purpose. The file name can contain the version number for ensuring that you have the latest file.
I'm doing some work for my theses in networking, and have stumbled into a little problem. One of the first steps in the work I must do consists on having a computer working as an AP (I am using hostapd for this) and with it, detect all the devices in the room which currently have wifi turned on (do not need to be associated with any AP).
I have found a thread that pretty much asks the same ( discover mobil devices using wifi ), and I understand the answers that were given, but they don't give any hint as to how this can be done. The post ends saying that the person was able to do this using Kismet, however I can only seem to use Kismet to discover clients already associated with an AP.
Can someone point me in the right direction here please? If not using Kismet, then maybe suggest a different tool that works with Ubuntu.
Ps. I will need to run a continuous scan of the "room" to find any new devices and then send this information to an event manager written in Java.
I guess you could have a WiFi card, in monitor mode, scanning every channel for beacons. On Linux, aircrack-ng is the tool suite you are looking for. airodump-ng is the tool that shows you a list of devices present around your location. It is designed to display first the hotspots with the potentials clients, but also shows all the devices that are connected to an AP or trying to probe to an AP.
However, you won't be able to scan devices having their WiFi connection turned down. I'm not sure about devices not associated to an AP, my guess is you will be able to detect them if they send beacons one way or another (for example, to detect WiFi hotspots).
If you need this in Java, you can write a wrapper to airodump-ng, or you can launch airodump-ng as a service outputing to a file and read this file from a Java app.
No concrete answer I'm afraid, but I hope these will help you figure a way to solve your problem.