I want to send email from terminal android application. Is there any command for this or any email functions?
I, too, want to be able to send emails from terminal/shell scripts in Android. It took me over a week to figure out how to do it. Obstacles included:
Android's default command line toolbox doesn't offer this functionality
The busybox (v1.22.1 bionic) on my android device (MotoG with CyanogenMod 11) seems to have been compiled without the sendmail applet (!?)
Judging from the fact that I was not able to find an answer to your question anywhere, it seems that not many people seem to care about this functionality
I finally did find a simple solution: curl. It is dead-simple to get it working, but only if you have root access to your device. Here's how to set it up:
A. On your computer (desktop or laptop):
Download the curl package for android available here: http://curl.haxx.se/download.html (scroll down until you find the version for android)
Extract the package's contents using your preferred application
B. Use USB cable to plug your android device into your computer
C. Copy the curl binary from your computer (/data/local/bin/curl in the extracted package) to somewhere in your android device's PATH (I copied it into the /system/xbin directory) and make sure that the file is executable
D. Disconnect device from your computer and happy emailing!
Now you can use curl at the command line (or in your shell scripts) to send emails. Usage example is here: Using curl to send email. You can even send text messages! (see here: http://osxdaily.com/2014/03/12/send-sms-text-message-from-command-line/)
Related
I am building an Ionic 4 App + PouchDB, I have built the app by executing the command ionic cordova run android and for a few days, it works well. Recently though, the app just won't open anymore and I have no idea how to check what went wrong.
Prior to this, whenever something went wrong in the app, I am able to check it using the chrome://inspect. However, with the app not being able to open at all, it's impossible to check the cause of the problem since I am also unable to check using chrome://inspect.
When I tried to run it using ionic cordova run android -l, I get the same result, which is the app loads and closes a few moments later, and I'm still unable to get into chrome://inspect.
I had a hunch that it has something to do with PouchDB. The app starts to behave this way when the storage is almost reaching 200mb. Upon reading the PouchDB FAQ, it's stated;
In PhoneGap/Cordova, you can have unlimited data on both iOS and Android by using the SQLite Plugin.
But I am already using the SQLite Plugin for PouchDB, I have used cordova-sqlite adapter for my PouchDB too.
Below is an example of line in my code:
this._userdb = new PouchDB('user.db', { adapter: 'cordova-sqlite'});
With the app being unable to open, I'm out of ideas on how to retrieve the data stored inside PouchDB since I can't even get into the chrome://inspect at all (I can't see any console.log() for the stored data).
I feel like clearing the app data would allow the app to be opened as how it used to be but I really need to do a backup of the data stored inside PouchDB but I really have no idea how other than getting the console.log() of the data.
Is there any other way I can access the data stored inside the PouchDB to do the backup?
After many failed attempts to figure out how to retrieve the data stored inside PouchDB , I found one solution which is to pull the APK and extract the backup file.
By referring to this article, open CMD and shell into your device by;
adb shell
Provided that you know the app's package name, proceed to pull the APK by running;
adb backup -noapk com.app.your.package.name
**Note: Some devices like Samsung Galaxy stock Android 11 requires password to 'Backup my data'
Once pulled, you will find a backup.ab file and you need to extract this file. At this step, as a Windows user, I was unable to use the openssl method. I get an error using Python too.
But I found a solution that worked well for a Windows user. According to that solution;
Download Android Backup Processor
Go into the directory android-backup-tookit\android-backup-processor\executable (this directory should have a abp.jar file
Copy your backup.ab into this directory.
Open CMD, and run;
java -jar abp.jar unpack backup.ab test.tar
If the device was required password during the backup process, you will be asked to enter password. Enter the same password you provided during backup. Be sure to read the README for further details.
Once done, you will find test.tar file in the same directory. To view the file, simply extract it. The databases created inside the app should be in \test\apps\com.yourappname\f. The sqlite databases files can be viewed using DB Browser for SQLite.
I'm developing an android application using Qt. As far as I understood the default path for deployment and installation of application is /data/user/0/... and this path is inaccessible unless my android device has been root. I would like to know if there is any possible way to change this path and make it accessible since I need to access some of the files in this directory.
Thank you some much for your help in advance!
As long as your device is not rooted, you can not access this location from other applications. If you just want to do it for development purposes, you can simply run
adb root
from the command line to access that location from the development host and thorough the adb.
For example, you will then have access to push/pull files from that location using a command like this in Windows
adb pull /data/user/0/.../somesqlite.db %USERPROFILE%\Desktop\
I need to access a UNIX domain socket from my Android app. Its file is located in /dev, so I need root permissions to open it. My phone is rooted, so gaining this permissions is not a problem. However, I failed to find a way to access this socket from root and forward the communication to my app.
AFAIK, the only way Android apps can get root permissions is through the su tool, so I need to find a native tool (already installed in the phone) that can make a bridge between STDIN/STDOUT and UNIX domain packets (so that my app can control the communication). The typical tools for that purpose are nc and socat. The former is available through busybox, but that version does not support UNIX domain sockets. The latter is not available at all. I'd rather avoid modifying the system partition to install a different tool.
My app could also launch a script that communicate with that socket from su directly without the need to forward the communication to my app, but again, I found no way to write such a script without the previously mentioned tools.
Is it possible to do what I want without installing/developing a native binary tool?
Maybe it is possible to do something with iptables/netfilter, but that does not seem to support this kind of sockets.
EDIT: well, I ended up developing a native binary executable which opens the Unix domain socket as root, and forwards it to the Java part using another Unix domain socket (created by the Java part). There is a hidden constructor for LocalSocket which takes a file descriptor and uses it as the opened socket. The biggest challenge was to find out how to compile a native executable with Android studio (not a library), but this answer helped a lot.
Suppose I've installed five apps in some mobile. I used them for few days, I would like to copy them to another mobile along with data using sdcard. Means in whatever mobile I put that sdcard, my all apps with the data should work fine. It's like cloning windows os and installing same state os to other, but only a selected apps in my scenario. Is it possible? Ask me you did not get question? Thank you.
Despite of you question is not about programing, your goal can be archived using adb tool from Android SDK.
Connect your first device to PC and use adb backup -apk -shared $package_name to create application backup file on your PC.
Then connect second device to PC and use adb restore to install the app.
How can I test an application for performance in Android? What is the support provided in Android and how do I use it?
If you want to profile your application to find performance bottlenecks you can use the traceview tool. This gives you a graphical view of performance traces of your application.
To create a trace add the following to your code where you want to start tracing:
Debug.startMethodTracing("myapp");
and then put the following when you want to stop tracing:
Debug.stopMethodTracing();
This will create a trace file call myapp.trace in the root directory of the SD Card. As it is written to the SD Card:
If you're using the emulator you'll need to add an SD card to your AVD.
You'll need to give you app permission to write the SD card by adding the following to your Manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Once the file has been created you'll need to copy it to your PC. You can do this using the adb command:
adb pull /sdcard/myapp.trace c:/my/dir/myapp.trace
Finally, start traceview giving it the full path to the trace file:
traceview c:/my/dir/myapp.trace
I did have some problems with traceview failing with OutOfMemory exceptions. I fixed this on Windows by changing the last line of traceview.bat from:
call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
to:
call java -Xmx1g -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
Adding the -Xmx1g option allows traceview to use more memory.
Also, theoretically, DDMS can get memory allocations for your program and then you can analyze the dump using profilers.
DDMS Reference.
The reason why I have theoretically in italics is that I myself have not tried doing anything such, yet.
I think traceView contains too much information, you can easily get lost.
My solution is just log the system time at three place in the code.
Before and after and center at the potiential slow code.
like binary search, next time, narrow it down step by step, then finally find the culprit code.
Another way to test is Using TruClient on Load Runner
Steps to be followed for Mobile Web are:
New VuGen Script
Mobile Protocol
Select TruClient Mobile Web
Click Create
Now you can generate scripts
Click Develop Script button
PoP up window appears to select the device
Select Actions and you can record the scripts
Steps to be followed for Native Mobile are:
New VuGen Script
Mobile Protocol
Select TruClient Native Mobile
Click Create
Now you can generate scripts
click develop script
TruClient window that plugged with Firefox appears
Click General Settings
Configure the SERVER URL PORT
If u don't know the server url port means install OS MONITOR application on your device. here you can find the ip address
Enter User Name and Password
Click done
you can record the scripts and perform your testing....
you can use load runner.,
use this link to find more about it.,
http://www.perftesting.co.uk/recording-and-performance-testing-android-applications-with-hp-loadrunner-vugen/2011/11/14/
Steps to be followed are:
Create New VuGen Script
Select Mobile Application-HTTP/HTML
Recording Options--> Select Record Emulator
Give the path to Record Emulator as D:\android\AVD Manager.exe
In the command line
-avd AVD_NAME -netspeed full -netdelay none
where AVD_Name is the name of your Device
select the working directory
click finish
Now you can perform your test.,