[MOD][XPOSED] ActivityForceNewTask

Search This thread

GermainZ

Inactive Recognized Developer / Retired Forum Mod
Aug 3, 2012
6,170
8,805
Introduction:
Apps can launch other apps' activities inside their task. This makes it impossible to switch back and forth between the two. This module sets the FLAG_ACTIVITY_NEW_TASK flag when starting a new activity, which 'fixes' that.
Originally requested by jacknicholson here.

Screenshots explanation:
attachment.php


Requirements:

Filtering:
  • A quick toggle is available in the settings. Just check "Disable module" and the changes will take effect immediately. No need to restart.
  • You can use the blacklist or the whitelist to filter activities. If the blacklist is selected, all activities except those excluded will launch in a new task. If you use the whitelist, only matching activities will launch in a new task instead. The preferred way to add entries is through the log.
The activity components are output to the logcat. You can filter it for "activityforcenewtask componentString:" to see them. A line is logged for every started activity (you probably don't want to keep the log constantly turned on.)
A log viewer is also present in the app. You can press a log entry to directly add it to the currently active list. I'd advise you to only enable the log when needed.

Source code:
https://github.com/GermainZ/ActivityForceNewTask

Download:
http://repo.xposed.info/module/com.germainz.activityforcenewtask

Changelog:
2.1.3:
  • Compatibility with Lollipop.
  • Added Spanish translation and updated Portuguese (Brazil) and Slovak translations. Thanks to Jose Artuñedo, meatboy371 and ja-som.
2.1.1:
  • The blacklist/whitelist settings are now only reloaded when necessary. Shouldn't make a big difference unless you have huge lists.
  • 4.4.3 fix: get the context using a different method (fixes logging on 4.4.3).
  • Added Portuguese (Br) translation by meatboy371.
2.0.3:
  • Only use context for logging;
  • Try to get the context in an alternate manner if the first one fails;
  • Bug fix: current package wasn't being detected properly;
  • Only start activities in a new task when the caller does not expect a result (different, more general implementation.)
2.0.2:
  • Reverted back to hooking ActivityRecord's constructor. Should solve the issue where some activities' launches weren't being detected.
  • Updated Slovak translation.
2.0:
  • Ignore activities that are launched by their own apps;
  • Added filtering options back. You can choose between the whitelist and the blacklist, but the no filtering option has been removed;
  • Added help dialogs for the whitelist/blacklist/log;
  • Bug fix: duplicate log entries when returning to the app with the log viewer open.
  • Other minor changes: use icons for action bar items, reorder preferences.
1.9:
  • Removed none/blacklist filtering options. The whitelist is always used now (renamed to "Enabled Components") which means that you must configure the module, as it won't do anything by default.
  • Reverted back to hooking Activity.startActivity(Intent, Bundle). Other methods used to start an Activity require the usage of FLAG_ACTIVITY_NEW_TASK, so it doesn't actually make sense to hook anything else. Also removed the alternate way to get a context as it shouldn't be needed anymore.
  • Check if FLAG_ACTIVITY_NEW_TASK is already set, and do nothing if that's the case (the activity won't be logged either.)
  • Updated Slovak translations (by ja-som.)
1.8.1:
  • Fix some crashes at startup;
  • Add FLAG_ACTIVITY_NEW_TASK flag instead of overwriting it. This fixes issues with XHalo and some apps showing in recents when they shouldn't;
  • Updated translations.
1.7:
  • Different hook, the previous one didn't catch all new activities.
1.6.1:
  • Removed unnecessary logging.
1.6:
  • Added whitelist.
1.5:
  • Added option to enable/disable the blacklist (and log.) The blacklist requires a few extra calls which are unnecessary if you don't use it, so I'd advise you don't enable it unless you need it.
  • Cleanup/better performance for the log viewer.
1.4:
  • The mod will now only modify intents that should be modified. This should fix all breakage without needing the blacklist. \o/
  • Log viewer improvements: tapping on an item now removes it from the list after adding it to the blacklist, and a toast is shown to indicate if it's been added to the blacklist.
1.3:
  • Use flat text file for storing the logs instead of SharedPreferences. This is much better for performance, especially if the log gets long.
1.2:
  • The blacklist is now for activities.
  • You can enable/disable logging from within the app.
  • Added log viewer to the app. You can tap a log entry to directly add it to the blacklist.
  • Fixes.
1.1:
  • Fixes for the two icons appearing in the launcher.
  • Disable text correction when adding a blacklist item.
1.0:
  • Initial release.

Thanks:
  • rovo89 and Tungstwenty for the Xposed Framework;
  • egingell for helping out with what to blacklist;
  • defim for advice on which intents to modify;
  • Ja_som for Slovak translation;
  • Sanguinus112 for German translation;
  • All testers. :)
 

Attachments

  • Screen.png
    Screen.png
    81.7 KB · Views: 250,942
Last edited:

Thomas_BA

Senior Member
Dec 22, 2009
1,122
250
Buenos Aires
www.artantique.net
Great idea, testing during the next days. So far only a cosmetic bug. After the installation of the module two icons appear in the launcher. Restart also did not change that.

Posting from the moon with Moto X and Tapatalk.
 

GermainZ

Inactive Recognized Developer / Retired Forum Mod
Aug 3, 2012
6,170
8,805

egingell

Senior Member
Apr 10, 2012
4,755
2,059
46
blog.sophielabuf.com
Thanks:
  • rovo89 for the Xposed Framework;
  • egingell for helping out with *what* to blacklist.

Thank you for trying to help me with my problem. I was looking at your SettingsHelper class and I think I need to start thinking of the Xposed side and Android side as separate apps and code it as such. But I'm too tired and achy to test right now.

Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9
 
  • Like
Reactions: vvvwtf and GermainZ

polobunny

Senior Member
Oct 25, 2011
6,223
2,312
Montreal
@GermainZ
Great idea. Would be nice if you clould find a way to detect apps which don't work and the blacklist could be removed

I'm not really sure how that could be achieved. @_@

The blacklist is good enough, but I feel like there's only going to be a handful of entries shared by specific people since people are morbidly afraid of logcat and I'm sure even more of filtering it.

Doesn't matter much in the end, I'm a happy user. Niche product for niche people?
 

egingell

Senior Member
Apr 10, 2012
4,755
2,059
46
blog.sophielabuf.com
I'm not really sure how that could be achieved. @_@

The blacklist is good enough, but I feel like there's only going to be a handful of entries shared by specific people since people are morbidly afraid of logcat and I'm sure even more of filtering it.

Doesn't matter much in the end, I'm a happy user. Niche product for niche people?

I can never get its built-in filter to work. I always have to resort to piping it through grep.

Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9
 

polobunny

Senior Member
Oct 25, 2011
6,223
2,312
Montreal
I can never get its built-in filter to work. I always have to resort to piping it through grep.

Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9

Not sure where the issue lies, but that's usually what I use
ie:
adb logcat Xposed:V *:S

Show everything Xposed, hides everything else for instance. You can go fancy and do other things but if you're just looking to extract something real quick that will do.
 

egingell

Senior Member
Apr 10, 2012
4,755
2,059
46
blog.sophielabuf.com
Not sure where the issue lies, but that's usually what I use
ie:
adb logcat Xposed:V *:S

Show everything Xposed, hides everything else for instance. You can go fancy and do other things but if you're just looking to extract something real quick that will do.

I do that, but it always seems to show everything anyway.

Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9
 

jacknicholson

Senior Member
Jun 23, 2013
555
442
EDIT: OUTDATED

Not sure if anyone else has been seeing a slight lag when selecting apps from Running Services, but blacklisting
Code:
com.android.settings.Settings$ManageApplicationsActivity
has solved it for me.
 
Last edited:
  • Like
Reactions: theknut

themadproducer

Senior Member
Aug 28, 2009
2,815
1,340
But I got another bug: If the launcher icon is hidden via your option you can't open the module from the module list because it says that your module doesn't have an UI. Reproducible.
I can confirm this. I was able to get back in by using System Tuner Pro to re-enable the Activity named Preferences Alias.
 

jacknicholson

Senior Member
Jun 23, 2013
555
442
EDIT: OUTDATED

Not a bug, but rather personal preference. If anyone's ROM settings ever open a separate package (eg. to pull up an additional settings page), and you don't want that cluttering up your Recents, add this:
Code:
com.android.settings.Settings
 
Last edited:

GermainZ

Inactive Recognized Developer / Retired Forum Mod
Aug 3, 2012
6,170
8,805
@GermainZ
To add to blacklist
Code:
com.android.internal.app.ResolverActivity
http://grepcode.com/file/repository...om/android/internal/app/ResolverActivity.java

If you want to be able to upload a picture through Tapatalk. I imagine there's a billion other uses to it. Might break module functionality in some cases? *shrugs*
That'll basically nullify the module's effect when you don't have a default app set. :p
(OUTDATED INFO)
@GermainZ
Great idea. Would be nice if you clould find a way to detect apps which don't work and the blacklist could be removed
I can't find any reliable method :(
The blacklist is good enough, but I feel like there's only going to be a handful of entries shared by specific people since people are morbidly afraid of logcat and I'm sure even more of filtering it.

Doesn't matter much in the end, I'm a happy user. Niche product for niche people?
I'm going to add a logger you can turn off and on when needed. Checking the logcat is better though because you sometimes need live input to decide (e.g. if an activity instantly launches another.)

But I got another bug: If the launcher icon is hidden via your option you can't open the module from the module list because it says that your module doesn't have an UI. Reproducible.
My fault, will be fixed in the next version.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 150
    Introduction:
    Apps can launch other apps' activities inside their task. This makes it impossible to switch back and forth between the two. This module sets the FLAG_ACTIVITY_NEW_TASK flag when starting a new activity, which 'fixes' that.
    Originally requested by jacknicholson here.

    Screenshots explanation:
    attachment.php


    Requirements:

    Filtering:
    • A quick toggle is available in the settings. Just check "Disable module" and the changes will take effect immediately. No need to restart.
    • You can use the blacklist or the whitelist to filter activities. If the blacklist is selected, all activities except those excluded will launch in a new task. If you use the whitelist, only matching activities will launch in a new task instead. The preferred way to add entries is through the log.
    The activity components are output to the logcat. You can filter it for "activityforcenewtask componentString:" to see them. A line is logged for every started activity (you probably don't want to keep the log constantly turned on.)
    A log viewer is also present in the app. You can press a log entry to directly add it to the currently active list. I'd advise you to only enable the log when needed.

    Source code:
    https://github.com/GermainZ/ActivityForceNewTask

    Download:
    http://repo.xposed.info/module/com.germainz.activityforcenewtask

    Changelog:
    2.1.3:
    • Compatibility with Lollipop.
    • Added Spanish translation and updated Portuguese (Brazil) and Slovak translations. Thanks to Jose Artuñedo, meatboy371 and ja-som.
    2.1.1:
    • The blacklist/whitelist settings are now only reloaded when necessary. Shouldn't make a big difference unless you have huge lists.
    • 4.4.3 fix: get the context using a different method (fixes logging on 4.4.3).
    • Added Portuguese (Br) translation by meatboy371.
    2.0.3:
    • Only use context for logging;
    • Try to get the context in an alternate manner if the first one fails;
    • Bug fix: current package wasn't being detected properly;
    • Only start activities in a new task when the caller does not expect a result (different, more general implementation.)
    2.0.2:
    • Reverted back to hooking ActivityRecord's constructor. Should solve the issue where some activities' launches weren't being detected.
    • Updated Slovak translation.
    2.0:
    • Ignore activities that are launched by their own apps;
    • Added filtering options back. You can choose between the whitelist and the blacklist, but the no filtering option has been removed;
    • Added help dialogs for the whitelist/blacklist/log;
    • Bug fix: duplicate log entries when returning to the app with the log viewer open.
    • Other minor changes: use icons for action bar items, reorder preferences.
    1.9:
    • Removed none/blacklist filtering options. The whitelist is always used now (renamed to "Enabled Components") which means that you must configure the module, as it won't do anything by default.
    • Reverted back to hooking Activity.startActivity(Intent, Bundle). Other methods used to start an Activity require the usage of FLAG_ACTIVITY_NEW_TASK, so it doesn't actually make sense to hook anything else. Also removed the alternate way to get a context as it shouldn't be needed anymore.
    • Check if FLAG_ACTIVITY_NEW_TASK is already set, and do nothing if that's the case (the activity won't be logged either.)
    • Updated Slovak translations (by ja-som.)
    1.8.1:
    • Fix some crashes at startup;
    • Add FLAG_ACTIVITY_NEW_TASK flag instead of overwriting it. This fixes issues with XHalo and some apps showing in recents when they shouldn't;
    • Updated translations.
    1.7:
    • Different hook, the previous one didn't catch all new activities.
    1.6.1:
    • Removed unnecessary logging.
    1.6:
    • Added whitelist.
    1.5:
    • Added option to enable/disable the blacklist (and log.) The blacklist requires a few extra calls which are unnecessary if you don't use it, so I'd advise you don't enable it unless you need it.
    • Cleanup/better performance for the log viewer.
    1.4:
    • The mod will now only modify intents that should be modified. This should fix all breakage without needing the blacklist. \o/
    • Log viewer improvements: tapping on an item now removes it from the list after adding it to the blacklist, and a toast is shown to indicate if it's been added to the blacklist.
    1.3:
    • Use flat text file for storing the logs instead of SharedPreferences. This is much better for performance, especially if the log gets long.
    1.2:
    • The blacklist is now for activities.
    • You can enable/disable logging from within the app.
    • Added log viewer to the app. You can tap a log entry to directly add it to the blacklist.
    • Fixes.
    1.1:
    • Fixes for the two icons appearing in the launcher.
    • Disable text correction when adding a blacklist item.
    1.0:
    • Initial release.

    Thanks:
    • rovo89 and Tungstwenty for the Xposed Framework;
    • egingell for helping out with what to blacklist;
    • defim for advice on which intents to modify;
    • Ja_som for Slovak translation;
    • Sanguinus112 for German translation;
    • All testers. :)
    14
    Never realized how annoying apps could be without this. I'll gladly donate if you could flash an AOSP ROM to update this to Lollipop and then do a restore back to TW!
    If you want to, please donate to someone who needs it more than I do. :) I noticed this post yesterday and I was planning to test if that's all what's needed for Lollipop support. A friend reported that it works, so please test it and let me know if it's fine for everyone as well. Again, I don't expect a donation and would rather see you give it to someone who needs it more than I do (or even rovo for his great work on Xposed).
    10
    Update:
    1.4:
    • The mod will now only modify intents that should be modified. This should fix all breakage without needing the blacklist. \o/
    • Log viewer improvements: tapping on an item now removes it from the list after adding it to the blacklist, and a toast is shown to indicate if it's been added to the blacklist.

    Enjoy! :D
    9
    As I've said above, the reason for removing the blacklist was that it's affecting other developers by having unaware users complain to them/throw low ratings, and I didn't want that. That being said, I'm all for what's easier for the user without those side effects, which is why I've been trying multiple ideas (and multiple methods for each) to try and get rid of those.

    I think 2.0 will be usable with the blacklist without affecting other apps (I've tested it with all the previous known issues and none of them are occurring.) I'm attaching a beta to this post for you guys to test, please report any issues and leave your feedback.
    Translators, please send an update when you can.

    Changes:
    • Ignore activities that are launched by their own apps;
    • Added filtering options back. You can choose between the whitelist and the blacklist, but the no filtering option has been removed;
    • Added help dialogs for the whitelist/blacklist/log;
    • Bug fix: duplicate log entries when returning to the app with the log viewer open.
    • Other minor changes: use icons for action bar items, reorder preferences.
    You need to clear the app's data.

    Also pasting a commit message here since it has some extra info and I'm too lazy to reword it:
    Since the module now ignores activities launched by and within their own
    apps, the blacklist shouldn't cause problems anymore, so I'm adding it
    back as the default. The 'None' option isn't needed anymore: it was
    originally added so some extra checks can be skipped, but they're now
    necessary anyway.

    If everything works as intended, I'll push this update to the repo in a day or two. :)
    9
    Minor update, mostly performance oriented:
    1.5:
    • Added option to enable/disable the blacklist (and log.) The blacklist requires a few extra calls which are unnecessary if you don't use it, so I'd advise you don't enable it unless you need it.
    • Cleanup/better performance for the log viewer.