4

I'm writing simple APN toggle app. I wanted to ask how to force android not show any window. Currently after running my app, for brief time Black screen with app name is shown and then disappears. Is it possible not to show anything ( only Toast message ) ?

public class ApnSwtichActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (toggleAPN()){
       Toast.makeText(this, "Apn switched", Toast.LENGTH_SHORT).show();
    }
    this.finish();
}}
Khobar
  • 486
  • 7
  • 20

3 Answers3

3

Sounds like you want an activity without a UI How to launch an Activity without a UI?

You'll probably want to use

android:theme="@android:style/Theme.NoDisplay"
Community
  • 1
  • 1
Quint Stoffers
  • 790
  • 8
  • 23
0

I don't think this is possible exactly as you want. You can hide title bar like this: add android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" in your manifest:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".TestActivity"
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
        >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Caner
  • 57,267
  • 35
  • 174
  • 180
0

You could create an activity, make it transparant and give it the parameters FLAG_NOT_TOUCH_MODAL & FLAG_NOT_TOUCHABLE
(FLAG_NOT_TOUCH_MODAL passes any touch input you give to your activity to the underlying screen, FLAG_NOT_TOUCHABLE negates any touch input commands for the activity)

Don't forget to make your activity autoclose after you're done

Andreas
  • 2,007
  • 5
  • 26
  • 37