Here is my handler code in which i set my progressbar in oncreate() method
     progressBar = (ProgressBar) findViewById(R.id.progressBar);
     thread = new Thread(new MyThread());
     thread.start();
     handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            progressBar.setProgress(msg.arg1);
                          }
       };
      if(progressBar.getProgress()==99)
    {
        Intent i = new Intent(SplashScreen.this,MainActivity.class);
        startActivity(i);
        finish();
    }
And here is the MyThread Class through which i sending message to handler
class MyThread implements Runnable{
    @Override
    public void run() {
        for (int i=0;i<100;i++){
            Message message = Message.obtain();
            message.arg1 = i;
            handler.sendMessage(message);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}//mythread
I want to start my main activity when progressbar complete its progress. but mesage.arg1 returns null Tell me where i am making mistake
This is the screen shot which andriod studio is generating to me
