0

在运行 android 7+(nougat) 的手机上,直到我在调试模式下运行我的代码,我的 ui 才会响应,但对于运行 android 版本 <7 的设备运行良好

这是 OnCreate 的活动代码:

    super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            threadForFirebaseReport();
            //Action Bar content
            toolbar = (Toolbar) findViewById(R.id.toolbar_main);
            //spinner.setVisibility(View.VISIBLE);
            frameLayoutMain = (FrameLayout) findViewById(R.id.main_fragment);

            //Fragments
            fragmentManager = this.getFragmentManager();
            homeFragment = new HomeFragment();

            progressDialog = new ProgressDialog(this);
            mapCity = new HashMap<Long, String>();
            cityItems = new ArrayList<String>();



            //backToolbarButton = (ImageView) toolbar.findViewById(R.id.toolbarback_button);
            /*actionBar = getSupportActionBar();*/
            sharedPreferences = this.getSharedPreferences(Constants.SHAREDPREFERENCE_FILENAME, Context.MODE_PRIVATE);
            setSupportActionBar(toolbar);

            //hiding default app icon
            actionBar = getSupportActionBar();
            actionBar.setDisplayShowHomeEnabled(false);
            //displaying custom ActionBar
            View mActionBarView = getLayoutInflater().inflate(R.layout.action_bar, null);
            actionbarImage = (ImageButton) mActionBarView.findViewById(R.id.toolbarback_button);
            actionbarText = (TextView) mActionBarView.findViewById(R.id.toolbar_text);
            actionBar.setCustomView(mActionBarView);
            actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
            getSupportActionBar().setElevation(0);
            actionbarImage.setOnClickListener(this);
            spinner = (Spinner) findViewById(R.id.spinner);

            threadForAppsFlyer();



            //For Navigation Drawer
            drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
            listViewDrawerLayout = (ListView) findViewById(R.id.drawer_list);
            navigationDrawerAdapter = new NavigationDrawerAdapter(getApplicationContext());
            listViewDrawerLayout.setAdapter(navigationDrawerAdapter);
            drawerLayout.setScrimColor(Color.TRANSPARENT);
            try {
                drawerLayout.setScrimColor(getResources().getColor(R.color.colorBlackAlpha));
            } catch (Exception e) {

            }
            listViewDrawerLayout.setOnItemClickListener(HomeActivity.this);


            //For navigation DrawerActionbar button
            actionBarDrawerListener = new ActionBarDrawerToggle(
                    this,
                    drawerLayout,
                    toolbar,
                    R.string.drawer_open,
                    R.string.drawer_close) {

                @Override
                public void onDrawerClosed(View drawerView) {

                }

                @Override
                public void onDrawerOpened(View drawerView) {
                    super.onDrawerOpened(drawerView);
                    editor = sharedPreferences.edit();
                    editor.putString("fragment", "0");
                    editor.commit();

                }
            };
            drawerLayout.addDrawerListener(actionBarDrawerListener);
changeHomeFragment();

每当我使用调试点在调试中运行代码并继续运行时,它就会开始工作,尽管这个问题出现在 android 版本中,直到 marshmallow。

4

0 回答 0