judemanutd / AutoStarter

This library helps bring up the autostart permission manager of a phone to the user so they can add an app to autostart.
MIT License
626 stars 115 forks source link

Added for react native project #62

Closed vandit560 closed 3 years ago

vandit560 commented 3 years ago

Intent flag added activity new task

judemanutd commented 3 years ago

@vandit560 could you elaborate a little more on how react native plays into this addition

mbouxin commented 3 years ago

The "fix" here is dueto the fact that @vandit560 tried to call your lib through a react Native context which is an application context and not an Activity context. In this situation, calling another activity requires the added flag.

IMHO the actual solution would be to change the call in react native application by using something like AutoStartPermissionHelper.getInstance().getAutoStartPermission(reactContext.getCurrentActivity())

judemanutd commented 3 years ago

@vandit560 could you make a change to accept a boolean parameter for the startIntent function. Based on the boolean, you can add an if clause around the FLAG_ACTIVITY_NEW_TASK so that way the end user can decide if they want to start the intent in the existing activity or a new task depending on their preference and use case.

judemanutd commented 3 years ago

Thanks for the PR, closing this one since it should be resolved in https://github.com/judemanutd/AutoStarter/pull/69