Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Developer
RapsFan
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
Accepted Solution

SplashScreen activity auto minimizes app

I have a SplashScreen Activity running in s Thread. Calling finish(); minimizes the app when the SplashScreen Activity finishes and the MainActivity starts. How can I finish the SplashScreen activity without calling finish?

 

public class SplashScreen extends Activity {
    
    /**
     * The thread to process splash screen events
     */
    private Thread mSplashThread;    

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Splash screen view
        setContentView(R.layout.splash);
        
        final SplashScreen sPlashScreen = this;   
        
        // The thread to wait for splash screen events
        mSplashThread =  new Thread(){
            @Override
            public void run(){
                try {
                    synchronized(this){
                        // Wait given period of time or exit on touch
                        wait(5000);
                    }
                }
                catch(InterruptedException ex){                    
                }

                finish();
                
                // Run next activity
                Intent intent = new Intent();
                intent.setClass(sPlashScreen, MainActivity.class);
                startActivity(intent);
                //stop();                    
            }
        };
        
        mSplashThread.start();        
    }
        
    /**
     * Processes splash screen touch events
     */
    @Override
    public boolean onTouchEvent(MotionEvent evt)
    {
        if(evt.getAction() == MotionEvent.ACTION_DOWN)
        {
            synchronized(mSplashThread){
                mSplashThread.notifyAll();
            }
        }
        return true;
    }    
} 

 

Please use plain text.
Developer
RapsFan
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Re: SplashScreen activity auto minimizes app

[ Edited ]

This did it:

 

mSplashThread =newThread(){@Overridepublicvoid run(){try{synchronized(this){// Wait given period of time or exit on touch
                    wait(5000);}}catch(InterruptedException ex){}// Run next activityIntent intent =newIntent();
            intent.setClass(sPlashScreen,MainActivity.class);
            startActivity(intent);//call finish after startActivity
            finish();//stop();                    }};

    mSplashThread.start();

 

Please use plain text.