Sunday, July 29, 2012

How to Change Main/Start Screen on Android?

Hello! As you known, there is nothing to say about developing  and progressive Android all around the world. In this situation, we can find any idea to make application. Actually, this is not so easy :) Namely what I am trying to say is that Android provides us to create applications and be a developer in mobile world.

I am sure that most of us have played a game via our mobile phones. Things I said above were for any application actually. Because, games, software about educations, politics, health education, voluntariness, etc applications  allow Android skills.

If you want to create an application to be used by everyone (this is very assertive :) ), you have to be different than other apps. This difference should be about design, software or your idea. 

In this article, I'll show you some codes about tiny difference, "starting page" on your Android application.

I want to tell you about my mind. Users download your app and install it on the phone. The next step will be starting your application. This step is so important. Because, people who use the app decide how good the app is. For that reason, how to start the app should be very important for us. In this context, I can start to code about this.

I've got two classes: Main.java and startingPage.java

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.startingPagexml);
        
        Thread MyScreen = new Thread() {
         public void run() {
          try {
           sleep(5000);
     
           startActivity(new Intent(getApplicationContext(),startingPage.class));
          } catch (InterruptedException e) {
           e.printStackTrace();
          }
          finally {
           finish();
          }
         }
        };
        MyScreen.start();
    }


The code given above is the first page will be opened on the app. Thread "MyScreen" helps to go another page. When the app opened, wait 5 second and go to the startingPage.class. startingPage.class includes startingPagexml.xml Android Xml file. This file calls the page after 5 seconds.


public class acilis2 extends Activity {

 public void onCreate(Bundle savedInstanceState) {
  Toast.makeText(this, "Welcome to My Application", Toast.LENGTH_LONG).show();
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 }


Toast.makeText(this, "Welcome to My Application", Toast.LENGTH_LONG).show();


This code introduces how to give user message after 5 second. If you want to see and learn more information about Toast notification, you can visit android developer official guide in here.


See you next article!

No comments:

Post a Comment

Thanks