1

I'm trying to run SyncMe only when computer is pingable. Since the app currently is not able to work this way, I'm using Tasker and its AutoShortcut plugin. SyncMe exposes an intent/shortcut which allows to run all sync jobs for a given computer. Tasker was then configured to run such shortcut under certain conditions and every two minutes.

The problem is that the shortcut will only run "once", any subsequent calls to the shortcut will not run the sync. This happens not only from within Tasker but also when adding the shortcut to home screen. When tapping the icon for the first time, UI shows up and the sync runs correctly. But if I press home button and tap it again, it will only return focus to the UI without any action being taken.

The only way I could figure out to make the shortcut run again was somehow "closing" the app, for example going to home screen with the back button or removing SyncMe from recent apps, none of which seems possible from within Tasker, I think it requires rooting.

0

Android gives activities a setting called launchMode, which allows them to control how and when they're launched. With some values of launchMode, starting the same activity again with an intent won't start a new activity: instead, it'll deliver the new intent to the existing activity. This might happen only if the activity is the foreground activity, or if it is anywhere in the current task (that is, if you can get to that activity just by pressing back repeatedly).

It's quite common for app authors to set launchMode to solve some kinds of programming or user interface problem, such as concurrency issues that arise from having two instances of the same activity running at once, one in the foreground and one in the background. When they do this, they don't always remember to write the code to handle the new intent the activity is sent by Android: the activity receives the intent a different way to when it's first launched.

It's hard to tell without knowing more about this app, but from the behaviour you describe, it sounds like SyncMe has fallen into this trap. You should tell the developer what you're trying to achieve, and ask them to fix it.

  • Not just from within Tasker but a home screen shortcut doesn't work either, only if I press the back button or remove SyncMe from recent apps, instead of directly using the home button to go back and tap the shortcut again. The developer said adding FLAG_ACTIVITY_CLEAR_TOP causes some side effects. So what flag would you suggest? The shortcut basically points to a configured computer or folder, and should run the related sync, but it won't run the sync when using home button to tap it again, instead it will only return to app screen. Help! – Renato Silva Sep 15 '13 at 19:59
  • @RenatoSilva I wouldn't suggest any flag. It's up to the app developer to fix this bug, either by resetting launchMode to normal, or by implementing onNewIntent. – Dan Hulme Sep 15 '13 at 21:00
  • Dan, did you check it yourself? Try running shortcut, home button and then run shortcut again and you see that no intent is delivered no matter what launchMode is used. Looks like Android bug to me. – user41506 Sep 16 '13 at 4:46
0

Home screen shortcut

We believe it's an Android bug. In fact, as I could confirm on a custom build, adding FLAG_ACTIVITY_SINGLE_TOP fixed the problem for home screen shortcuts, despite its documentation indicating pretty the opposite, as below. We find those docs very poorly written, at least. According to the developer, this fix is going to work as long as main app activity stays on top (that is, editing a sync job then pressing home button for tapping icon again is not going to work).

If set, the activity will not be launched if it is already running at the top of the history stack.

Tasker and AutoShortcut

For some reason, the above fix does not work in AutoShortcut. I don't know how different the intent sent by this plugin is from that of the home screen shortcuts. Either way, I have reported the problem to the developer. Regardless, I also just have set up a direct intent configuration in Tasker, instead of using AutoShortcut, as follows:

  • Action: com.bv.wifisync.run
  • Extra: itemId:<id>
  • Package: com.bv.wifisync
  • Class: com.bv.wifisync.Hosts
  • Target: Activity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.