1,Service Intent must be explicit: Intent
不要以为你想什么代码都知道,还是要写出来滴~~。比方这个,你一定没有告诉代码你要打开哪个activity或者service.
正确姿势:Intent intent=newIntent(Activity.this, Service.class);
2,xml预览时Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'textViewStyle' in current theme
3, Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
原来是我重写Activity的onCreate方法时,重写了public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState),并没有默认调用它,默认调用的是protected void onCreate(Bundle savedInstanceState),所以并没有执行setContentView(),界面也没有任何东西。看来就算会自动补全还是要记住方法的参数,还是要好好选,不能啪一下回车就过了。