0

I wonder how it is possible to simulate a button click to launch an app through its shortcut? I have seen automation apps such as Automagic (perhaps also Tasker) do this. Are they using AccessibilityServices? If yes, how would I call such a shortcut -do I use "performGlobalAction()"?

Edit: What I really after is to emulate/simulate a click on a button or a shortcut which apps such as Tasker can do. For instance, Google Assistant cannot be opened programatically (see How to start Google Assistant programatically?) due to permission denail. However, it can be opened by clicking on a shortcut on the screen opened according to the following instructions: https://www.ytechb.com/how-to-get-google-assistant-on-any-android-lollipop-device-without-root/

With Tasker I can then add an action which opens this shortcut. Now I am wondering how Tasker does this programatically.

moster67
  • 830
  • 3
  • 12
  • 30

1 Answers1

0

You can launch another android app by using an Intent. To get the launch intent for another application you can use the

Context.getPackageManager().getLaunchIntentForPackage(String packagename);

If this is not null, then the app is installed on the device and you can launch it. If you want to get a list of other apps on the device you can use

Context.getPackageManager().queryIntentActivities(Intent intent, int flags);

You can find more information of these by looking at the PackageManager Docs

Nic Robertson
  • 1,198
  • 9
  • 26
  • What you say is OK but as far as I know not applicable in my case. Perhaps I was to vague. I have edited my question and hopefully this explains better what I am asking – moster67 Sep 18 '17 at 19:24