android - Implement if/else -


i want implement code set color of navigation bar if android version above 5.x.x :

how can implement if-statement?

  • edit:

for want to:

string _osversion =         android.os.build.version.release;      if (_osversion.tostring().startswith("5"))     {         toast.maketext(getapplicationcontext(), "your android version are: \n\n" + _osversion, toast.length_short).show();         window window = this.getwindow();          window.clearflags(windowmanager.layoutparams.flag_translucent_status);          window.addflags(windowmanager.layoutparams.flag_draws_system_bar_backgrounds);          window.setstatusbarcolor(this.getresources().getcolor(r.drawable.indigodark));          window.setnavigationbarcolor(this.getresources().getcolor(r.drawable.indigodark));      }      else if (_osversion.tostring().startswith("6"))     {          window window = this.getwindow();          window.clearflags(windowmanager.layoutparams.flag_translucent_status);          window.addflags(windowmanager.layoutparams.flag_draws_system_bar_backgrounds);          window.setstatusbarcolor(this.getresources().getcolor(r.drawable.indigodark));          window.setnavigationbarcolor(this.getresources().getcolor(r.drawable.indigodark));      }      else     {         toast.maketext(getapplicationcontext(), "your android version under 5.x.x", toast.length_short).show();     } 

use this:

if ( build.version.sdk_int >=           build.version_codes.lollipop ) {  //code } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -