[Solved] app crashing because of ‘Caused by: java.lang.NullPointerException’ error [closed]


Hey you are are getting exception on something like this code

your_toggle_button.setChecked(true);

The above code is in other class rather than your_toggle_button activity because you can’t touch your activity’s child if the activity is not running, to achieve this you will have to save your value in some variable and send it through intent when you start activity of that view and get that value there in that activity and change state of the view accordingly.

So Always keep in mind you can’t touch any activity’s view when activity is not running and even when you didn’t initialize the view

4

solved app crashing because of ‘Caused by: java.lang.NullPointerException’ error [closed]