Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!BuildConfig.DEBUG) { <START> Bugsnag.init(this); <END> } setContentView(R.layout.activity_main); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!userLearnedDrawer) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); userLearnedDrawer = true; Log.d(TAG, "User learned drawer"); } } }; drawerLayout.setDrawerListener(actionBarDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(this); getSupportLoaderManager().initLoader(0, null, this); StoreCredentials storeCredentials = new StoreCredentials(this); if (storeCredentials.token() == null) { AccountManager manager = AccountManager.get(this); Account[] accounts = manager.getAccountsByType(getString(R.string.account_type)); if (accounts.length > 0) { Account account = accounts[0]; AccountsHelper.getUserToken(this, account); storeCredentials.storeToken(AccountsHelper.getUserToken(this, account)); storeCredentials.storeUsername(account.name); storeCredentials.storeScopes(AccountsHelper.getUserScopes(this, account)); } } }</code><technical_language>docs, this called in Application, in Activity: > In application's onCreate function, initialize Bugsnag capturing exceptions: > > java > Bugsnag.init(this); > <LINK_0></technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); userLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close){ @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!userLearnedDrawer) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); userLearnedDrawer = true; Log.d(TAG, "User learned drawer"); } } }; drawerLayout.setDrawerListener(actionBarDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(this); getSupportLoaderManager().initLoader(0, null, this); StoreCredentials storeCredentials = new StoreCredentials(this); if (storeCredentials.token() == null) { AccountManager manager = AccountManager.get(this); Account[] accounts = manager.getAccountsByType(getString(R.string.account_type)); if (accounts.length > 0) { Account account = accounts[0]; AccountsHelper.getUserToken(this, account); storeCredentials.storeToken(AccountsHelper.getUserToken(this, account)); storeCredentials.storeUsername(account.name); storeCredentials.storeScopes(AccountsHelper.getUserScopes(this, account)); } } }