adb command to turn on FM - android

I looked up and down but did not come across anything.
Is there any ADB command or android way to to turn on FM in an android phone? Or i will have to create and app to do this?

You might be able to use Activity Manager commands from adb
adb shell am start -a <some intent>
or
adb shell am startservice -a <some intent>
but you should read the question Android Intent to launch radio application
Unless you can find out what the intent is called then you may be completely stuck.

Related

Android ADB Open URL in current tab/close previous tabs

I am currently using the following to open a tab in the native browser on an android device
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk"
The issue I have is that each time the command is sent it open a new tabs. To combat this I have tried to kill the browser in an attempt to start again howevre, the previous tab are remembered.
adb shell am force-stop com.android.browser
I did previously try a kill, but this did not seem to work
adb shell am kill com.android.browser
I did some quick reading and found the option create_new_tab but I believe this to be for chrome and not the native browser.
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk" --ez create_new_tab false
Does anyone know how a single tab can be used and either open a tab if one does not exist, or use the existing one if it does. I am using windows command line.
I was able to reuse the same browser tab with the following command:
adb shell am start -a "android.intent.action.VIEW" -d "http://www.google.com" --es "com.android.browser.application_id" "com.package.name"
Some documentation can be found here:
https://developer.android.com/reference/android/provider/Browser.html#EXTRA_APPLICATION_ID

How can I launch the App Info screen for my app through ADB?

I want to launch the App Info screen for my app through adb. I tried to fire an intent using "adb shell am start" but nothing seems to work. I need something that works at least for API levels 18 and 19. Can anyone help?
Open App Info
adb shell am start -a android.settings.APPLICATION_DETAILS_SETTINGS package:com.your.packagename
For Example: if you want to open Chrome App Info
adb shell am start -a android.settings.APPLICATION_DETAILS_SETTINGS package:com.android.chrome
adb shell am start -n yourpackagename/.activityname

How to kill a process started by android am

I use the following command to start playing a movie on my android device:
adb shell am start -d file:///sdcard/fff.wvm -t video/3gp -a android.intent.action.VIEW
I want to stop (kill) the process before it finishes. Does anyone know the process name "am start" command create? I used ps to get the running processes in the background, but there is a lot, and it is hard to tell which one is.
If you know the package being started, use:
adb shell am force-stop <PACKAGE>
For me com.android.gallery worked pretty fine, however this depends on the installed app and preferred apps, of course. Going i.e. pushing Back might end the playback - it least it worked with the system player:
adb shell input keyevent 4
Appending the command ...
adb shell am kill-all
... should kill the process afterwards.

Launch any application on emulator via terminal

How do I launch any application via a terminal or command shell on android emulator engine? For example, if I want to start any game, how do I do via a terminal or command shell?
Anyone could help is really appreciated.
Thanks,
Sam.
You can use the am start command trough adb.
Example for the browser app floating around the internet:
am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity

Stopping an Android app from console

Is it possible to stop an Android app from the console? Something like:
adb stop com.my.app.package
It would speed up our testing process so much. Right now we uninstall/install the app each time to make sure the manual test cases start with a clean state.
The clean way of stopping the app is:
adb shell am force-stop com.my.app.id
This way you don't have to figure out the process ID.
Edit: Long after I wrote this post and it was accepted as the answer, the am force-stop command was implemented by the Android team, as mentioned in this answer.
Alternatively: Rather than just stopping the app, since you mention wanting a "clean slate" for each test run, you can use adb shell pm clear com.my.app.package, which will stop the app process and clear out all the stored data for that app.
If you're on Linux:
adb shell ps | grep com.myapp | awk '{print $2}' | xargs adb shell kill
That will only work for devices/emulators where you have root immediately upon running a shell. That can probably be refined slightly to call su beforehand.
Otherwise, you can do (manually, or I suppose scripted):
pc $ adb -d shell
android $ su
android # ps
android # kill <process id from ps output>
First, put the app into the background (press the device's home button)
Then....in a terminal....
adb shell am kill com.your.package
you can use the following from the device console: pm disable com.my.app.package which will kill it. Then use pm enable com.my.app.package so that you can launch it again.
If you have access to the application package, then you can install with the -r option and it will kill the process if it is currently running as a side effect. Like this:
adb -d install -r MyApp.apk ; adb -d shell am start -a android.intent.action.MAIN -n com.MyCompany.MyApp/.MyActivity
The -r option preserves the data currently associated with the app. However, if you want a clean slate like you mention you might not want to use that option.
If you target a non-rooted device and/or have services in you APK that you don't want to stop as well, the other solutions won't work.
To solve this problem, I've resorted to a broadcast message receiver I've added to my activity in order to stop it.
public class TestActivity extends Activity {
private static final String STOP_COMMAND = "com.example.TestActivity.STOP";
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
TestActivity.this.finish();
}
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//other stuff...
registerReceiver(broadcastReceiver, new IntentFilter(STOP_COMMAND));
}
}
That way, you can issue this adb command to stop your activity:
adb shell am broadcast -a com.example.TestActivity.STOP
The "stop" command is implemented as force-stop; stops background app from running. If it's in foreground, it'll stop also: eg.
adb shell am force-stop com.android.providers.telephony
Clearing of packages also deletes their data eg.
adb shell pm clear com.android.providers.telephony
will delete all your sms
Be careful which one you choose.
adb shell killall -9 com.your.package.name
according to MAC "mandatory access control"
you probably have the permission to kill process
which is not started by root
have fun!
If all you are looking for is killing a package
pkill package_name
should work
I tried all answers here on Linux nothing worked for debugging on unrooted device API Level 23,
so i found an Alternative for debugging
From Developer Options -> Apps section -> check Do Not keep activities
that way when ever you put the app in background it gets killed
P.S remember to uncheck it after you finished debugging
In eclipse go to the DDMS perspective and in the devices tab click the process you want to kill under the device you want to kill it on. You then just need to press the stop button and it should kill the process.
I'm not sure how you'd do this from the command line tool but there must be a way. Maybe you do it through the adb shell...
pkill NAMEofAPP
Non rooted marshmallow, termux & terminal emulator.

Categories

Resources