Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot receive intent after activity is restored. #28

Open
miklcct opened this issue May 22, 2024 · 2 comments
Open

Cannot receive intent after activity is restored. #28

miklcct opened this issue May 22, 2024 · 2 comments

Comments

@miklcct
Copy link

miklcct commented May 22, 2024

Describe the bug
The intent is not received after the activity is restored after it is killed.

To Reproduce
Steps to reproduce the behavior:

  1. Enable "Don't keep activities" in the developer settings.
  2. Create a StatefulWidget to receive intents.
  3. Call the activity using an Intent.

Expected behavior
The intent is received

Sample code

class _HomePageState extends State<HomePage> with RestorationMixin<HomePage> {
  final initialIntentProcessed = RestorableBool(false);
  late final Stream<Intent?> intentStream = () async* {
    if (!initialIntentProcessed.value) {
      yield await ReceiveIntent.getInitialIntent();
      initialIntentProcessed.value = true;
    }
    yield* ReceiveIntent.receivedIntentStream;
  } ();

  @override
  Widget build(BuildContext context) => SizedBox();

  @override
  String? get restorationId => 'HomePage';

  @override
  void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
    registerForRestoration(initialIntentProcessed, 'initialIntentProcessed');
  }


  @override
  void initState() {
    super.initState();
    _intentSubscription = intentStream.listen((event) {
      if (event == null) return;
      debugPrint("Intent received: $event");
      }
    });
  }

  @override
  void dispose() {
    _intentSubscription.cancel();
    super.dispose();
  }
}

The intent is received normally if the activity is not killed (when the developer setting is disabled), but not when the activity is killed.

@daadu
Copy link
Owner

daadu commented Oct 17, 2024

I'm unaware about this setting, do you know how to fix this? I might take time to work on it.

@miklcct
Copy link
Author

miklcct commented Oct 17, 2024

It's been a while after I posted this, but I am thinking the problems may be required to some issue in my code and different various scenarios:

  1. Start the activity using a geo: intent, switch to another activity such that it will be killed, and switch it back (the initial geo: activity is returned again which I don't want to handle).
  2. Start the activity using a geo: intent, switch to another activity such that it will be killed, and start it from the map using a geo: intent again (this geo: activity might become the new initial intent? If so how can I distinguish between case 1?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants