1

When I change the storage permission, I can't read the data stored in the memory

NullPointerException: Attempt to read from field'LanguageInitBean$Data LanguageInitBean.data' on a null object reference

Change permissions in settings at app runtime

Ask for help

public static class LanguageInitCache{
    public static LanguageInitBean languageInitBean;
}
private void startToNext(String response) {
    languageInitBean = GsonUtils.json2Bean(response, LanguageInitBean.class);
}
  • Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – vincrichaud Dec 07 '21 at 08:09
  • What should I do when the data in memory is empty after changing permissions – ningzhaobin Dec 07 '21 at 09:00

1 Answers1

0

Check whether it is empty in advance in my base class, and then to startPage(SplashActivity)

if (!(this instanceof SplashActivity)){
        if (Constants.LanguageInitCache.languageInitBean==null){
            startActivity(new Intent(getBaseContext(),SplashActivity.class));
            finish();
            return;
        }
    }