Wednesday, 18 February 2015

Prevent Android File Transfer From Opening Each Time A Device Is Connected

First things first, I know it's been a while since I made a blog and the reason for this is that I have recently moved across country for a new job (which I love!). Things are still pretty busy for me so I'm not sure how regular this will be updated.
Anyway today I'm going to go through a little trick I discovered while using Android File Transfer on Mac OS. If you are familiar with this program and you are a developer then you have probably got annoyed with it constantly popping up every time you plug in your device.
Everytime I plug in my device Android File Transfer pops up over everything else. This is fine when I want to actually use the program, however if I'm coding or just charging my device I do not want this. Especially with coding this can get very annoying.
The obvious solution might be to remove the program from the Mac's startup items. This doesn't work, at all! 
So here's the workaround, first make sure the program is currently closed:

Step 1 - Open Activity Monitor

Open the Activity Monitor application from your Utilities folder on your Mac’s hard drive. Sort the list of running apps by name by clicking on the “Name” column header. Look for the Android File Transfer Agent service in the list. Click on it, and then click on the Quit button at the top – the big red stop sign button. This kills the service for the time being.

Step 2 - Open Terminal Window

Open a Terminal window, and paste the following command into it and press Enter. This removes the File Transfer Agent service from the Application Support folder on your hard drive.
rm -r ~/Library/Application\ Support/Google/Android\ File\ Transfer/Android\ File\ Transfer\

Step 3 - Paste Command

In the Terminal window, paste the following commands and press Enter after each one. This changes into the directory of the File Transfer app bundle, and then renames the exiting service agent with a .DISABLED extension.
cd /Applications/Android\ File\
mv Android\ File\ Transfer\ Android\ File\ Transfer\


That's it, all done. Now when you plug your device in AFT should not open up. To use AFT now just simply open the program while the device is plugged in and it should operate as normal.
If you would like to change this back then you're in luck as it's even simpler. Just paste this command back into the Terminal window to rename the service back to its original name.
mv Android\ File\ Transfer\ Android\ File\ Transfer\

2018 Update!

It's been a while since I even thought about this blog but having recently set up AFT on a new Mac I noticed that the above method didn't seem to work. So after a quick Google I stumbled across a new method that seems to work. The below command is long but it essentially does the 3 above steps along with removing the application from the "System Events" list.
PID=$(ps -fe | grep "[A]ndroid File Transfer Agent" | awk '{print $2}'); if [[ -n $PID ]]; then kill $PID; fi; mv "/Applications/Android File File Transfer" "/Applications/Android File File Transfer Agent"; mv "${HOME}/Library/Application Support/Google/Android File Transfer/Android File Transfer" "${HOME}/Library/Application Support/Google/Android File Transfer/Android File Transfer Agent"; osascript -e 'tell application "System Events" to delete every login item whose name is "Android File Transfer Agent"

No comments:

Post a Comment