I am developing an application in which I have to put as well as get some files from Computer(i.e Windows system) using USB.
I searched the web but didn't get anything helpful. I have an idea about command line so I am able to do this by using commands like
./adb -s emulator-5554 pull /sdcard/juned.jpg c:/user/juned/images/
It will copy juned.jpg file in specified directory of system, but is it possible to run same command programmatically ?
Till now I got one sample application in Android Samples named AdbTest which is available under /root/android-sdks/samples/android-18/legacy/USB/ directory, I have tried to compile that application but it shows nothing.
In that application under xml directory device_filter.xml file is there. In that file
<resources>
<usb-device class="255" subclass="66" protocol="1" />
</resources>
What value should I provide to make it working with my device ?
And is it possible to run adb commands from indide an application programmatically?
Edit
So far I came to know that, adb command can not be executed in non rooted devices, so is there any other way to transfer files using USB ?
Its not possible for Devices which are not rooted
Since to run your command it requires Su permission (Super User) .
Your command will be system/bin/ Su / -command
non rooted device don't have access to system/bin/ Su
you can root your emulator by Installing Superuser.apk
or try How to get root access on Android emulator?
Related
I tried on my own but failed , when I looked around I didn’t find except tool called adbd insecure which make me can run this command
“adb root”.
when I run this command I got no response on CMD and when I tried to use this program mentioned above on my phone I got an error.
when the desired action when I run the command "adb root" om my Windows 10 OS
is "adbd is already running as root" in CMD.
So far I can run "adb pull /data/data & put it everywhere on my PC".
Any help please.
Okay, so here are the steps that works for me.
I'm a Linux user so you can later convert terminal commands to windows if necessary:
Since you mentioned that your device is already rooted:
adb devices--> Make sure your device is connected.
adb shell--> runs shell command on your device.
su --> gives you root access.
cd data/data --> (data/data/xyz) is apparently the file you want to pull).
pwd--> will display the path.
copy that path and save it somewhere.
use "exit" to get out from the shell.
Once you are back in C:\Program Files (x86)\Android\android-sdk\platform-tools, run adb pull (paste the path that you copied).
Now you should have your file. Hope that helps.
I have just learnt using preferences in Android. For debugging purpose I need to access the preferences files. I googled and found the default location of the preference file and also how to access it via Android Device Monitor.
Somehow I am not able to open any folders under the File explorer tab of the Android device monitor. They just aren't responding. I tried waiting for ADM to load and tried again but no success. (Double click on folder is not working, STRANGE!)
Do we need to configure before using it? I am using Android studio.
Any help would be appreciated.
Attaching image
Finally I found how to make it work.
goto run -> location where your adb is
Ex: C:\Program Files (x86)\Android\android-sdk\platform-tools
type adb root , Enter (Your phone must have root)
If this doesn't work, install this app on your phone: [root] adbd Insecure or its free alternative here (update: link broken now).
Get more info at http://forum.xda-developers.com/showthread.php?t=1687590
You will need either to use the emulator or to have a rooted phone to use all functionalities.
Root your device and open adb shell and change the permissions as:
$ adb shell
$ su
1|root#android:/ # chmod -R 777 data/
Hi so my application runs some commands using the su in android root.
It works fine in JellyBean on the Galaxy Nexus but when I try to run it on the LG Nexus 5 (kitkat), I get an error saying:
su: uid 10069 not allowed to su
I'm not really sure what I'm missing here. I have root access (it runs su fine on the Galaxy Nexus).
Basically the application reads in a command from a TextEdit, strips it, appends the necessary parameters etc. and then calls the script which is put on the phone. I use the ProcessBuilder to build the call for the script.
Any fixes or ideas as to where I should look would be appreciated. Thank you
The issue was SuperSu not being properly installed and granting permission to the application. Once I changed that there were no permissions issues.
If you have problem with rooting to super user.
You can use "run-as" command to access files of your application.
ex: run-as com.your.package
It will drop you to the shell#android:/data/data/com.your.package $
now you can use commands ls
Then it will display the list of file folders
cache
databases
lib
shared_prefs
Can anyone give me a step by step instruction on how to try the D2XX Sample on this one:
http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_134_FTDI_Android_D2XX_Driver.pdf
im having troubles trying it on my device. as per requirement. my device is already rooted and i have also ndk-build the files but its showing force close when i ran the project.
Following are the steps you need to take in order to run the sample demo.
install the sample application on your android device.
connect your device via adb.
access your device using adb shell.
type cd /dev/bus/usb
then type ls
you should see directories such as 001 and 002.
go to each directory e.g., cd 001 .
then use the following command to give your application access to usb:
chmod 666 *
start your application and it should now detect your ftdi device and you would be able to transmit and receive data.
Install the application on your android box.
I want to write a small tool to move apps to SDcard.
I found the movePackage()-method in Android Open Source and reflect the method. I failed because this method need com.android.PERMISSION.MOVE_PACKAGE which I cannot get. So I want to using shell script to do this for rooted devices.
But I don't actually know what happened in the movePackage()-method. So I can't write the correct script.
Could you please tell what happened inside the Android when a app is moved to SDcard? Can I do this with program?
I'm not sure If I understand you, but on rooted device you can use adb.
For example:
adb push /home/username/Desktop/app.apk /sdcard/app.apk
Also you can do this (for removing):
adb shell rm /sdcard/app.apk
If you want to install:
adb install /home/username/Desktop/app.apk