有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何解决安卓中的“致命信号11(SIGSEGV),代码1,tid 18101中的故障地址0x1d”错误?

此错误发生在我的启动屏幕中。我尝试了很多清除缓存和删除的方法。格雷德尔文件和所有。我的应用程序使用SharedReferences来跟踪某些活动。这是我的启动活动代码。我尝试在manifest中禁用Android硬件加速,但是它停止了所有的动画和图形,这不是一个很好的解决方法

public class SplashActivity extends AppCompatActivity {

private LoginModel userInfo = null;
private int fieldId;
private LiveData<LoginModel> loginModelLiveData;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    //transparent status bar
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    getWindow().setStatusBarColor(Color.TRANSPARENT);
    this.getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
    );
    SharedPreferences prefs = getSharedPreferences(getString(R.string.RyosharedPref), MODE_PRIVATE);
    String number = prefs.getString("phone", null);
    fieldId = prefs.getInt("fieldId", 0);

    RyoGasRepository ryoGasRepository = new RyoGasRepository(getApplication());
    loginModelLiveData = ryoGasRepository.getUser(number);
    loginModelLiveData.observe(this, new Observer<LoginModel>() {
        @Override
        public void onChanged(LoginModel loginModel) {
            if (loginModel != null) {
                userInfo = loginModel;
            }
            startAnimations();
            loginModelLiveData.removeObserver(this);
        }
    });
}

private void startAnimations() {

    Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
    anim.reset();
    LinearLayout l = findViewById(R.id.splash_linear);
    l.clearAnimation();
    l.startAnimation(anim);

    anim = AnimationUtils.loadAnimation(this, R.anim.translate);
    anim.reset();
    ImageView iv = findViewById(R.id.ryo);
    iv.clearAnimation();
    iv.startAnimation(anim);

    // Splash screen pause time
    // do nothing
    Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                int waited = 0;
                // Splash screen pause time
                while (waited < 2500) {
                    sleep(50);
                    waited += 100;
                }
                if (userInfo == null) {
                    startActivity(new Intent(SplashActivity.this, LoginSignUpActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));
                } else {
                    if (fieldId != 0) {
                        startActivity(new Intent(SplashActivity.this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));
                    } else {
                        startActivity(new Intent(SplashActivity.this, GasPumpListActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION));
                    }
                }
                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                finish();

            } catch (InterruptedException e) {
                // do nothing
            } finally {
                SplashActivity.this.finish();
            }
        }
    };
    splashTread.start();
}

@Override
public void onBackPressed() {
}

}


共 (0) 个答案