How to clear all activity stack in Android

Normally when we launch new activity, it’s previous activities will be kept in a queue like a stack of activities. So if you want to kill all the previous activities, just follow these methods. Method 1 In API level 11 or greater, use FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY_NEW_TASK flag on Intent to clear all the activity stack.

Android stop or start adb from command line

Sometimes your android emulator might fails to connect eclipse DDMS tool and ask for adb to start manually. In that case you can start or stop the adb using the command prompt. Method 1 Open the cmd from Start ⇒ run ⇒ cmd and execute these commands. Before you execute the commands in CMD make …

Android getting application context in Fragments

If your activity class extends Activity, you can get application context using getApplicatoinContext(). But this method won’t be available when your Activity extends from Fragment. Method 1 When your activity extends Fragment, use getActivity () to get the context of the activity.

Android Showing and Hiding the views

You can show and hide android views (layout, button, textview etc.,) at any time. You can also use animations like fadeOut or fadeIn to make it more beautiful while hiding and showing the views. Please refer Android Working with XML Animations if you want to add animations to view while hiding/showing. Using view.setVisibility(int) function you …

How to detect Android Back button press

Detecting android device hardware back button / soft back button press is very easy. But be careful while overriding the default back button action as it is not suggested to change the android default user experience. Method 1 Override the onBackPressed() method and take the action inside this function.

Android make activity as Fullscreen (Removing Title Bar or Action Bar)

If want to make an activity to fullscreen in some cases like playing video in fullscreen mode, playing game etc., you can do that by following one of the methods. Method 1 One way is using Theme.Holo.Light.NoActionBar.Fullscreen value in AndroidManifest.xml file. (Use the appropriate theme name whichever you used in your application) Method 1 Another …

Page 2 of 3123