At last I was able to find this example...

http://www.wglxy.com/android-tutorials/splash-screen-demo-app-for-android

and code the following, which seems to work for a splash screen with
AsyncTask:

public class GameActivity extends Activity {

  private Panel panel = null;

  class SplashTask extends AsyncTask<Void, Integer, Void> {

    GameActivity gameActivity;

    SplashTask(GameActivity gameActivity) {

      this.gameActivity = gameActivity;

    }

    @Override
    protected Void doInBackground(Void... params) {

      Looper.prepare();

      this.gameActivity.panel = new Panel(gameActivity);

      return null;

    }

    @Override
    protected void onPostExecute(Void params) {

      setContentView(this.gameActivity.panel);

    }

  }

  class Panel extends SurfaceView implements SurfaceHolder.Callback {

    Context context;

    public Panel(Context context) {

      super(context);

      this.context = context;

[...snip...]

  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // panel = new Panel(this);

    // setContentView(panel);

    setContentView(R.layout.splash);

    new SplashTask(this).execute();

    PowerManager powerManager = (PowerManager)
getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);

    wakeLock.acquire();

  }

And yes, also in my manifest file:

    <activity
      android:name=".GameActivity"
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
...

Thank you for all your kind replies,

As always, feedback welcome,

Regards,

John Goche

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to