Android系统也提供了一种称为“Service”的组件通常在后台运行.Activity 可以用来启动一个Service,Service启动后可以保持在后台一直运行,即使启动它的Activity退出或是切换到别的应用Service也能保持运行状态. Service 可以以两种形式存在: Started 当一个如Activity使用startService()来启动一个Service,一旦Service启动后,就不受启动它的Activity控制, 可以在后台长期运行,通常这种Service在后台…
1.Sending Notifications to the User (发送通知) Once running, a service can notify the user of events using Toast Notifications or Status Bar Notifications. A toast notification is a message that appears on the surface of the current window for a moment t…
1.在service中重写下面的方法,这个方法有三个返回值, START_STICKY是service被kill掉后自动重写创建@Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; }---------------- @Override public int onStartCommand(Intent intent…