Posts

Showing posts from August, 2017

How to surf trough screens using screen timeout

Assume you have two activities First Activity and Second Activity. To go to the second activity from the first activity without tapping add the below code into the 'onCreate' class in the activity. Here we use the android Handler getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);new android.os.Handler().postDelayed(new Runnable() { @Override public void run() { Intent i1 = new Intent(FirstActivity.this, SecondActivity.class); startActivity(i1); } }, 3000); According to the above code the time it takes to go to the next screen it takes 3 seconds (3000 milli seconds)

Adding app bar to a single activity when it is removed from the styles.xml file

Add the following code into the .xml file <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> If you want to add a text into the app bar then add the following code into the onCreate class of the relevant activity. Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(myToolbar);