Android How to hide notification bar -


i have been trying hide notification bar, making app full screen:

i have tried few sample codes not work, there were:

1# android:theme="@android:style/theme.holo.noactionbar.fullscreen"

2#

requestwindowfeature(window.feature_no_title);         getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,                                 windowmanager.layoutparams.flag_fullscreen);          setcontentview(r.layout.activity_main); 

see below logcat errors:...

here code, help:

mainactivity

import android.os.bundle; import android.support.v4.app.fragment; import android.support.v7.app.actionbar; import android.support.v7.app.actionbaractivity; import android.view.menu; import android.view.menuitem;  public class mainactivity extends actionbaractivity {      public static final string tag = mainactivity.class.getsimplename();      actionbar actionbar;      // declare tab variable     actionbar.tab tab1, tab2, tab3;     fragment fragmenttab1 = new fragmenttab1();      fragment fragmenttab2 = new fragmenttab2();     fragment fragmenttab3 = new fragmenttab3();       @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);           //hide action bar         actionbar = getsupportactionbar();                       // hide actionbar icon         actionbar.setdisplayshowhomeenabled(true);         // hide actionbar title         actionbar.setdisplayshowtitleenabled(true);         // create actionbar tabs         actionbar.setnavigationmode(actionbar.navigation_mode_tabs);          // set tab icon , titles         tab1 = actionbar.newtab().settext("asian");//.seticon(r.drawable.tab1);         tab2 = actionbar.newtab().settext("euro");         tab3 = actionbar.newtab().settext("black");          // set tab listeners         tab1.settablistener(new tablistener(fragmenttab1));         tab2.settablistener(new tablistener(fragmenttab2));         tab3.settablistener(new tablistener(fragmenttab3));          // add tabs actionbar         actionbar.addtab(tab1);         actionbar.addtab(tab2);         actionbar.addtab(tab3);      }//-----end oncreate  //action bar of appcombat -------------------------------------------------------------------------     @override     public boolean oncreateoptionsmenu(menu menu) {          // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();         if (id == r.id.action_settings) {             return true;         }         return super.onoptionsitemselected(item);     } }//--end body 

themes.xml

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="customtheme" parent="android:theme">          <item name="android:windowtitlebackgroundstyle">@style/windowtitlebackground</item>          <item name="android:windowfullscreen">true</item>        </style>  </resources> 

styles.xml

<resources>      <!--         base application theme, dependent on api level. theme replaced         appbasetheme res/values-vxx/styles.xml on newer devices.     -->     <style name="appbasetheme" parent="theme.appcompat.light">         <item name="android:windownotitle">true</item>         <!--             theme customizations available in newer api levels can go in             res/values-vxx/styles.xml, while customizations related             backward-compatibility can go here.         -->     </style>      <!-- application theme. -->     <style name="apptheme" parent="appbasetheme">         <!-- customizations not specific particular api-level can go here. -->     </style>      <style name="myimageview">         <!-- 3dp background border visible -->         <item name="android:padding">3dp</item>         <item name="android:background">@drawable/image_border</item>         <item name="android:scaletype">fitcenter</item>     </style>       <style name="windowtitlebackground">         <item name="android:background">@color/titlebackgroundcolor</item>     </style>  </resources> 

**logcat log: of sample 2# **

06-26 11:18:01.753: d/androidruntime(19490): shutting down vm 06-26 11:18:01.753: w/dalvikvm(19490): threadid=1: thread exiting uncaught exception (group=0x411172a0) 06-26 11:18:01.753: e/androidruntime(19490): fatal exception: main 06-26 11:18:01.753: e/androidruntime(19490): java.lang.runtimeexception: unable start activity componentinfo{com.example.brazilapps/com.example.brazilapps.mainactivity}: java.lang.nullpointerexception 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2110) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2135) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread.access$700(activitythread.java:140) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread$h.handlemessage(activitythread.java:1237) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.os.handler.dispatchmessage(handler.java:99) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.os.looper.loop(looper.java:137) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread.main(activitythread.java:4921) 06-26 11:18:01.753: e/androidruntime(19490):    @ java.lang.reflect.method.invokenative(native method) 06-26 11:18:01.753: e/androidruntime(19490):    @ java.lang.reflect.method.invoke(method.java:511) 06-26 11:18:01.753: e/androidruntime(19490):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) 06-26 11:18:01.753: e/androidruntime(19490):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) 06-26 11:18:01.753: e/androidruntime(19490):    @ dalvik.system.nativestart.main(native method) 06-26 11:18:01.753: e/androidruntime(19490): caused by: java.lang.nullpointerexception 06-26 11:18:01.753: e/androidruntime(19490):    @ com.example.brazilapps.mainactivity.oncreate(mainactivity.java:46) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activity.performcreate(activity.java:5188) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1094) 06-26 11:18:01.753: e/androidruntime(19490):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2074) 06-26 11:18:01.753: e/androidruntime(19490):    ... 11 more 

first of all, have changed layout name in sample your layout name? have tried in way?

requestwindowfeature(window.feature_no_title);     getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,                             windowmanager.layoutparams.flag_fullscreen);      setcontentview(r.layout.activity_main); // not r.layout.main 

then code doing? think it's not hiding

//hide action bar     actionbar = getsupportactionbar();                   // hide actionbar icon     actionbar.setdisplayshowhomeenabled(true);     // hide actionbar title     actionbar.setdisplayshowtitleenabled(true); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -