Note that there are some explanatory texts on larger screens.

plurals
  1. POPreventing onDraw() function from restarting during config changes
    primarykey
    data
    text
    <p>I have an activity which basically sleeps for a time and initialize another activity. During this sleep time I make some animated drawings on screen.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); View splashScreen = new SplashScreenView(this); setContentView(splashScreen); Thread splashThread = new Thread(){ public void run(){ try{ sleep(6500); startActivity(new Intent("com.example.LOGIN")); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ finish(); } } }; splashThread.start(); } </code></pre> <p>But when the screen orientation changes, the activity was restarting. So I handled it by modifying manifest file.</p> <pre><code>&lt;activity android:name=".SplashScreenActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>I have one problem left. I prevent activity from restarting but the onDraw() function in my SplashScreenView class still restarts.</p> <pre><code>protected void onDraw(Canvas canvas) { canvas.drawBitmap(dstbmp2, logoX, logoY, null); canvas.drawBitmap(dstbmp, ballX, ballY, null); // Update the position of the ball. update(); // Delay try { Thread.sleep(100); } catch (InterruptedException e) { } invalidate(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload