Navigation Drawer hangs while opening/closing on some devices

Course Queries Syllabus Queries 3 years ago

3.46K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


While working with my android app, I found out that navigation drawer hangs while opening as well as closing. It hangs for 2-3 seconds. On most devices, it's fine (mostly with Stock Android) but on some devices, it hangs (Mostly Samsung).

Home.java (activity in which drawer is implemented):

public class Home extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener{

    Fragment fragment;

    public void MsgBox(String title, String msg,int id){
        new LovelyInfoDialog(this)
                .setTopColorRes(R.color.primary)
                .setIcon(R.drawable.ic_info_white_24dp)
                //This will add Don't show again checkbox to the dialog. You can pass any ID as argument
                .setNotShowAgainOptionEnabled(id)
                .setTitle(title)
                .setMessage(msg)
                .show();
    }

    public boolean showAds() {
        SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        boolean showAd = getPrefs.getBoolean("showAd", true);
        return showAd;
    }

    public static boolean hasPermissions(Context context, String... permissions) {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context != null && permissions != null) {
            for (String permission : permissions) {
                if (ActivityCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
                    return false;
                }
            }
        }
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        hasPermissions(this,Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.GET_ACCOUNTS);
        
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum