startActivity(ⅰ);显示错误

时间:2017-06-22 08:28:12

标签: java android

它在"startActivity(i);"中显示错误。

  

错误:Activity中的startActivity(android.content.Intent)不能   应用

此处的代码:

public class LoadingScreen extends AppCompatActivity {

    private static int SplashInterval = 2000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_screen);

        new Handler().postDelayed(new Runnable(){
            @Override
            public void run(){
                //TODO Auto-generated method stub
                Intent i = new Intent(LoadingScreen.this, MainActivity.class);
                startActivity(i);

                this.finish();
            }
            private void finish(){
                //TODO Auto-generated method stub
            }
        },SplashInterval);
    };
}

3 个答案:

答案 0 :(得分:0)

试试这个,

QueryBuilders.nestedQuery("classes.links",
    QueryBuilders.boolQuery()
        .must(QueryBuilders.termQuery("classes.links.name", "xyz"))
).innerHit(new QueryInnerHitBuilder())

答案 1 :(得分:0)

试试这个

 new Handler().postDelayed(new Runnable() {

        /*
         * Showing splash screen with a timer. This will be useful when you
         * want to show case your app logo / company
         */

        @Override
        public void run() {
            Intent i = new Intent(LoadingScreen.this, MainActivity.class);
            startActivity(i);
            finish();

            // close this activity
        }
    }, SplashInterval);

答案 2 :(得分:0)

删除此行

this.finish();

写在处理程序

而是LoadingScreen.this.finish(); 实现此活动的结束;