@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DUBwisePrefs.init(this); if (DUBwisePrefs.keepLightNow()) { if (mWakeLock == null) { final PowerManager pm = (PowerManager) (getSystemService(Context.POWER_SERVICE)); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "DUBwise"); } mWakeLock.acquire(); } // do only once if (!did_init) { // BluetoothMaster.init(activity); VoicePrefs.init(this); StatusVoice.getInstance().init(this); BlackBoxPrefs.init(this); // start the default connection StartupConnectionService.start(this); if (BlackBoxPrefs.isBlackBoxEnabled()) { DUBwiseBackgroundHandler.getInstance().addAndStartTask(BlackBox.getInstance()); } did_init = true; } if (VoicePrefs.isVoiceEnabled() && !DUBwiseBackgroundHandler.getInstance() .getBackgroundTasks() .contains(StatusVoice.getInstance())) { DUBwiseBackgroundHandler.getInstance().addAndStartTask(StatusVoice.getInstance()); } setContentView(R.layout.base_layout); contentView = (ViewGroup) findViewById(R.id.content_frame); drawerList = (ListView) findViewById(R.id.left_drawer); drawerList.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { IconicMenuItem item = ((IconicMenuItem) (drawerList.getAdapter().getItem(position))); if (item.intent != null) { startActivity(item.intent); } } }); refresh_list(); // mTitle = mDrawerTitle = getTitle(); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle( this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { // getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { // getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerLayout.setDrawerListener(drawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // a little hack because I strongly disagree with the style guide here // ;-) // not having the Actionbar overfow menu also with devices with hardware // key really helps discoverability // http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore - but at least we tried ;-) } }