How to launch an Activity without a UI?

Is it in any way possible to launch an activity from the main function without having a UI? i.e. is there a way to create a sort of “wrapper” around another activity, i.e. by launching the main activity, it takes you to another activity automatically.

If that is not possible, is there a way to remove the main activity from the stack so that clicking the back button does not take you to a blank UI?
Here’s an example of what I’m trying to do:

  • Are there android intents to add data to Google keep
  • How to create an always running background service?
  • How to Draw graph in Android?
  • How to override (or hide) style attributes defined in the Android library project?
  • Phonegap 2.4 Android Proguard config
  • Why is it necessary to use @+id instead of @id?
  • public class WrapperActivity extends Activity {
        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState) {
            final Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-1212"));

    Related posts:

    How to update fragment content from activity (viewpager)?
    Themes in Android?
    USB interface in android
    What is the alternative to getActionView() before API level11 in android?
    Dynamic GridLayout
    Passing File with intent, how do i retrieve it
  • Set drawable size programmatically
  • No rule to make target NDK
  • Android tests without emulator
  • Maven vs Ant for automatic builds in Android applications
  • Unable to create F# Android Project - Visual Studio 2015 Xamarin Community
  • How do I properly import HttpClient from org.apache on Android using gradle build file?
  • 10 Solutions collect form web for “How to launch an Activity without a UI?”

    You need to add the Intent flag,



    call “finish();” after firing the intent.

    Android also provides a theme specifically for this:


    In your manifest, when you declare the activity, use theme "@android:style/Theme.Translucent.NoTitleBar"


    <activity android:name="yourActivityName" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">


    <activity android:name="yourActivityName" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">

    mentioned by Brian515 works great. This method is useful for creating an entry point Activity that decides on which activity to call, start, services, etc without having to show a UI to the user. Remember to use finish() after you have started your intent.

    I think this would help you a lot:

    <activity  android:name = "MyActivity" 
              android:label = "@string/app_name" 
              android:theme = "@android:style/Theme.NoDisplay" >

    Looks similar to the question asked here: Removing an activity from the history stack

    If it is, then you can use:


    This should work to wipe activities off of the stack.

    If you need to exclude from recent apps (long press home key) you can use this flag:


    In your manifest add @android:style/Theme.Translucent.NoTitleBar" as mentioned in some of the answers above.

    Also remove the setContentView(R.layout.your_activity); line from your file.

    If you are not interacting with the UI, what you are trying to do sounds more like an android service.

    I had used moveTaskToBack(true) in onResume() to put the entire activity stack in background.

    Just in case you are using Android 6.0+ or Target SDK is 23+, having a theme android:theme = "@android:style/Theme.NoDisplay" will lead to a crash with error did not call finish() prior to onResume() completing. This in fact is a bug recognised by Google developers here.

    So it is recommended to use an activity with following theme as a workaround.

    android:theme = "@android:style/Theme.Translucent.NoTitleBar"

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.