c19354837 / react-native-system-setting

A library to access system setting, and change it easily. eg: volume, brightness, wifi
MIT License
442 stars 159 forks source link

calling startActivity() from outside of an Activity context issue #138

Open Kaz-z opened 3 years ago

Kaz-z commented 3 years ago

Hi,

I intermittently receive errors about 'calling start activity from outside of an activity context' when I call the setVolume method.

I believe its due to a new activity being called here https://github.com/c19354837/react-native-system-setting/blob/7fd99df1161bffcc5ddda876ea48918a5cac2c24/android/src/main/java/com/ninty/system/setting/SystemSetting.java#L306

One solution would be to add intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) above the line before starting the activity.

What do you guys think?

moigamijunior commented 3 years ago

Well, I got the same issue when using setVolume(0, {type: 'ring'}). Some news?

Kaz-z commented 3 years ago

Its intermittent for me weirdly enough. After a clean / rebuild i dont see the error anymore. Im sure ill see it again so its best to fix this. I can contribute the change back.

Only thing is I dont know if the maintianers are active with PRs or releases.

timh1004 commented 2 years ago

I have the same issue sometimes when using setVolume(0, {...}).