On my phone the app Bluetooth Share crashes randomly. With Tasker I want to be able to detect that crash, and then force close Bluetooth Share and finally launch Bluetooth Share again. (Or turn on Bluetooth again)

PS: I already have tasker and I am rooted on CM12.1.

Any help is appreciated. Thanks!

  • 1
    I could've tried posting an answer but I don't have any such app which crashes randomly. I would suggest watching logcat to see if the crashes has some intent or broadcast related info. If the crash doesn't relaunch the app then you may take a bit of help from this answer (hint: mFocusedActivity)
    – Firelord
    Jun 8, 2015 at 15:40
  • Could Tasker Process Running (KC) allow you to detect when the app closes? play.google.com/store/apps/details?id=org.kc.tasker.processes
    – LJD200
    Jun 11, 2015 at 19:03
  • @LJD200 that app only checks if an app is running or not, it can't detect an app crash.
    – Thomas Vos
    Jun 11, 2015 at 19:12
  • @SuperThomasLab Does this Bluetooth Share relaunches itself after crash or you have to manually do it again including enabling the on/off? Also, does this crash happen when it's running in background (when you're doing something else) or when it's in foreground? // Do you have any other app that behaves alike or do you want strictly a solution for Bluetooth Share only. (I can't test or create a solution unless I have such app)?
    – Firelord
    Jun 11, 2015 at 19:15
  • @SuperThomasLab Do Android apps not close when they crash though?
    – LJD200
    Jun 11, 2015 at 19:17

2 Answers 2


Unfortunately, it's quite not possible. Tasker cannot detect an app crash.

However, we can still do something about it.

Let's first make a profile that does the killing job. It will be executed when the bluetooth goes off.

  • Profile (name): BTrern

    • State (Context): BlueTooth Status [ Status:Off ] (Profile triggers when BT goes off)
    • Task: (You can give task a name)

      • A1: Kill App [ App:Bluetooth Share Use Root:On ]      (Click the + to add these actions)
      • A2: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]       (Wait for 5 seconds)
      • A3 (optional): [X] Launch App [ App:Bluetooth Share]       (If you need to launch it)
      • A4: Bluetooth [ Set:On ]     (Turns ON blutooth)`

Note: If killing even with root is not working (there could be some problem with your Tasker or root), you can try the following shell command:

am force-stop packagename


am force-stop com.google.android.apps.maps

Or if that doesn't work:

  • pm disable
  • Wait 3 seconds
  • pm enable

Now, the next question is how to turn off Bluetooth without executing the instructions noted above?

It's quite simple. Make another task.

  • Profile Status: BTrern → Off
  • Wait 5 seconds
  • Bluetooth → Off

Name this task (like BTOFF) and make a shortcut to your home screen.

Now whenever you want to turn off your BT use this shortcut.

Let's make another task that turns on BT as well as the BTrern

  • Bluetooth → ON
  • Wait 5 sec
  • Profile Status → BTrern : ON

Again, use the above two task shortcuts to turn BT ON or OFF.

You can also use a scene or a widget to make it even easier once you have acquired enough knowledge with Tasker..


I do not quite understand what you mean by Bluetooth share, but I would presume you mean the activity opened by Share → Bluetooth. May be a pic or two would help.

Instead of finding a way around, first try fixing it by:

  • Using a Log tool like catlog. (Open catlog → set it on Error, let the crash occur and then open catlog again and save the log.)
  • Searching for it. You haven't provided any info about your Android model so you might have to do it yourself.

In case those doesn't work, we can use Tasker. I believe the crash will occur within few seconds of opening the activity. We can use this to our advantage.

  • TRIGGER ON: (When Bluetooth Share activity opens)

    • If (Bluetooth Share activity close) AND (qtime < 5 sec)

      • start (Bluetooth Share activity)
    • else (goto 1)`

Here, qtime is a local variable which stores for how many seconds the task is running. You can find that in Help section of Tasker.

Also you can use Tasker Process Running (KC) for the required process.

Second Method:

Instead of that, it's much more easier to make a Scene instead of that.

  • Just make a small box with one button in it which will execute the activity. Keep it non - intrusive.
  • Scene1:

    • Kill Bluetooth Share process
    • Start Bluetooth Share process
  • TRIGGER ON: (When Bluetooth Share activity opens)

    • Create Scene1

      • If (Bluetooth Share activity close)

        • wait 5 seconds
        • destroy scene1

With this, there will be a small overlay when you open Bluetooth Share. If it crashes you can easily execute your kill and start command. And if it doesn't crash, the scene will get automatically destroyed after 5 seconds.

May be Bluetooth File transfer can help.

  • Great answer, however ''Bluetooth Share'' crashes randomly. So not when I open an activity, share a file etc. I am going to try the logcat
    – Thomas Vos
    Jun 13, 2015 at 15:18
  • To simply put, use a Scene to force-stop and relaunch Bluetooth Share. Btw, can you please be more clear what you mean by "Bluetooth share"? A Pic can say 1000 words!
    – Abhioxic
    Jun 13, 2015 at 15:19
  • ![Do you mean this?][1] [1]: i.stack.imgur.com/wp98n.jpg Heres how to use logcat
    – Abhioxic
    Jun 13, 2015 at 15:25
  • yes, and this is the "Bluetooth (share)" app: imgur.com/peB7kV7
    – Thomas Vos
    Jun 13, 2015 at 15:29
  • Bluetooth share is not only the sharing part, but the whole bluetooth app. It doesn't crash when I try to share a file, but it occurs randomly. And it is very annoying because I have an Android Wear device. I've got a Samsung Galaxy S4 with Cyanogenmod 12.1 and also look at my question on the Cyanogenmod forum here: forum.cyanogenmod.org/topic/…
    – Thomas Vos
    Jun 13, 2015 at 15:36
  • Profile context App: Bluetooth Share
  • Enter Task

    • A1: Stop
  • Exit Task

    • A1: Bluetooth Share

Is this what you want?

  • Doesn't that only detect when Bluetooth is turned off. Maybe I should explain my reason why I want to detect a crash. On my phone Bluetooth crashes randomly. I want tasker to be able to force stop Bluetooth and then launch it again. I want to detect a crash because if I manually turn off Bluetooth that it stays of and doesn't turn on again. Is this detailed enough?
    – Thomas Vos
    Jun 12, 2015 at 8:19
  • Understood, you could make rule only trigger when bluetooth is on
    – rebane2001
    Jun 12, 2015 at 8:26
  • But still, if you add a rule if Bluetooth is on. When I turn Bluetooth off then it will also get past the rule, won't it?
    – Thomas Vos
    Jun 12, 2015 at 8:27
  • I don't think so, try it out and tell me if it worked
    – rebane2001
    Jun 12, 2015 at 8:29
  • OK, but can you make a detailed answer with the steps. I am new to tasker. Only got it for a week or so. For example I halve know what "A1" is. Thanks
    – Thomas Vos
    Jun 12, 2015 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .