2013年2月25日 星期一

onCreate和onStart是不同的


onCreate和onStart是不同的
通过从客户端调用Context.startService(Intent)方法我们可以启动一个服务。如果这个服务还没有运行,Android将启动它并且在onCreate方法之后调用它的onStart方法。如果这个服务已经在运行,那么它的onStart方法将被新的Intent再次调用。所以对于单个运行的Service它的onStart方法被反复调用是完全可能的并且是很正常的。


  1.  @Override  
  2.     public void onStart(Intent intent, int startId) {  
  3.         Log.e(TAG, "start onStart~~~");  
  4.         super.onStart(intent, startId);   
  5.     }  

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...