1

I want to make an app such that, when you install it, it shows no screen/UI but just changes your ringtone and couple of other settings on the phone. I don't mind the app icon showing ont he list of apps. Here's what I tried :

-- since setContentView sets the content for the UI, I removed it from the MainActivity.onCreate() but I still get a white screen on app launch. I don't see a reference to my activity_main.xml anywhere else in my code.

-- I can't seem to find anyone else who has the same issue. Google and forum search don't yield anything that is similar to my situation.

-- Preference fragments are a close match but theyy do need a UI again.

Can someone suggest an approach I can take to accomplish this? I know this sounds like a virus, but it's more of a fun prank app I am developing to prank my friends. Thanks in advance

LeoNeo
  • 739
  • 1
  • 9
  • 28
  • you can use a [service](http://stackoverflow.com/questions/21772458/android-application-without-gui) – code monkey Nov 02 '14 at 20:50
  • If its just a fun app: Start the activity, show black screen, apply settings, close activity with the finish method in the onCreate of the Activity and your done. – Rolf ツ Nov 02 '14 at 21:02
  • Creating a service also looks like a solution but I tried the below solution by CommonsWare and it worked perfectly fine. Thanks for your prompt answers. Encourages me to ask questions more often :) – LeoNeo Nov 02 '14 at 21:26

1 Answers1

3

since setContentView sets the content for the UI, I removed it from the MainActivity.onCreate() but I still get a white screen on app launch

Use Theme.NoDisplay in your manifest:

    <activity
        android:name="BootstrapActivity"
        android:theme="@android:style/Theme.NoDisplay">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

and be sure to call finish() at the end of onCreate().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491