> I doubt that you will find anything to do step c in Termux, you should
> do a wider search for this kind of feature.
My goal is a universal solution for anyone, even noobs, where Linux seems to
be the most powerful approach (but if I could find _anything_ that works,
I'd use it - but if I have to _build_ the approach, I'll try Linux first).
Besides, I've run scores of searches already seeking a tutorial, where the
ability to run any Android Activity from a single tap on an icon (or
automatically upon events such as homescreen wakeup) certainly exists in
automation tools such as typical payware Tasker solutions.
<
https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm>
They may even exist in freeware tasker-replacement solutions but most appear
to be "fremium" tools which just annoy the hell out of me in every way.
<
https://www.maketecheasier.com/tasker-alternatives-for-android/>
Even so, there aren't any extent tutorials (AFAIK) for how to bring up any
given Android Activity just from knowing the name of the Activity.
Or, maybe it exists, but I've asked on the Android newsgroup, and we have
never found a tutorial that works where you have to keep in mind syntax is
atrociously delicate when working with named Android activities.
> I know this kind of thing existed for MS-Windows some decades ago, and
> it would be straightforward in X-Windows, but with increased security
> for GUIs it may not be that easy to achieve.
The goal is to bring up _any_ Android Activity at a single tap - not just
the one simple reset-ad-id Activity we chose as the first test.
That means we need to bring up the Android Activity by name alone.
If we eliminate that strict requirement of only knowing the name and nothing
else, we already long ago solved the problem of bringing up an Activity by
searching for it in any of a number of free Android Shortcut Creator apps
(all previously cited in this thread).
a. We can run a free "Inspector" to find the name of the Activity
b. We can run a free "Shortcut Creator" to create a shortcut to it
c. But we still can't (yet) press buttons on that Activity (such as "reset")
The main reason for latching on to Linux scripting is done in the faith that
"Linux can do anything you want it to do), where I always knew that we'd
want to _interact_ with the Activity after we brought it up on the phone.'
A. We want a one-tap shortcut inside a desktop folder
B. You want that one-tap to bring up any Activity by name
C. And then you want it to auto interact with that Activity (& close it)
With your help I resolved A & B above with shell scripting inside Termux.
What I'm working on now is the shell command to press that "reset" button.
Bear in mind this is just the simplest Activity that I know of.
The goal is to be able to interact with _any_ Activity.
>> Here are cut and paste instructions anyone can follow.
> [ ... ]
>> 4. Run the F-Droid Termux and create an alias we'll name "rad" for reset ad id.
>
> This step is superfluous.
The _syntax_ on bringing up an Android Activity by name is unforgiving.
The alias is the simplest way I know to doublecheck the name is correct.
I agree the alias creation is superfluous, however, I'm writing up the steps
for newbies to follow in a tutorial that allows them to bring up _any_
Android Activity by name, where the alias is a simple and reliable "baby
step" for them to check the syntax that doesn't involve shell scripting.
> You're using bash for scripting where sh would suffice, this is a bad
> habit - I know that may not be relevant to you now, but for further
> endeavours into scripting this should be kept in mind.
As what tends to happen with solutions that are being worked out for the
first time, we take the _first_ solution that works (not necessarily the
best solution). Thank you for letting me know bash isn't the best shell.
Right now I'm focusing solely on the survival of the solution...
(we can hone it later)
It's much like evolution...
> Also 'am' is not a Termux command, it's built into android and can
> also be called from adb (but that lacks the widget option).
Oh! The adb command is on Android? Good. That may give us options.
<
https://play.google.com/store/search?q=adb%20android%20debug%20bridge&c=apps>
Yikes. There are so many adb tools on Google Play I'm not sure which is the
right one (as I always strive to use the canonical tool in every tutorial).
> In fact this command:
> $ adb shell 'while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done &'
As with all this Activity stuff, syntax is the bitch.
(Which is why a step-by-step tested working tutorial is what is needed.)
(And that is what I'll write when I get this to finally work.)
I test all viable suggestions before responding to them.
Hence I ran that (verbatim) Linux command on Windows over a USB tether to
the phone. Predictably it had minor syntax errors which I show only by way
of example of how nicely linux-like the Android phones' response was.
* daemon not running; starting now at tcp:5037
* daemon started successfully
/system/bin/sh: no closing quote
''' is not recognized as an internal or external command,
operable program or batch file.
C:\> adb shell "'while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done &'"
inaccessible or not found
C:\> adb shell \'while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done &\'
/system/bin/sh: syntax error: unexpected 'do'
'\'' is not recognized as an internal or external command,
operable program or batch file.
C:\> adb shell "'while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done \&'"
inaccessible or not found
C:\> adb shell ''while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done &''
'''' is not recognized as an internal or external command,
operable program or batch file.
C:\> adb shell "while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done \&"
/system/bin/sh: syntax error: unexpected '\&'
Finally this worked (normally I'd omit the errors but it shows how Android
is very linux like in its responses to syntax errors - which is good).
C:\> adb shell "while true ; do sleep 10 ; am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity ; done &"
BTW, to close just one Activity, this command works fine normally:
C:\> adb shell am force-stop com.google.android.gms
C:\> adb shell am force-stop com.android.settings
But in your infinite loop above, it only killed one instance at a time.
> Provided more fun than I was prepared to handle.
Yes, I saw why you said I'd see all kinds of fun thereafter! :)
That popped up the "reset ad id" Activity on the phone in an infinite loop
of sorts, where I get the all kinds of fun only after having run it. :)
Even after a "control C" in the adb window, the fun kept going.
Also after closing the adb window in Windows, the fun kept going.
This adb infinite loop is a good example where the "kill -9" on Android
works to get rid of it without needing to restart the phone otherwise.
Notice even this failed to stop the infinite loop:
C:\> adb shell stop
Must be root
Of course, this always works to get back control of the phone! :)
C:\> adb reboot