Android Broadcast调用Service做的一个定时器
2010-08-20 02:13:00 来源:WEB开发网核心提示:11. }12. }public class AlarmService extends Service {public IBinder onBind(Intent intent) {return null;}public void onCreate() {// 只在创建时执行一次}public void onStart
11. }
12. }
public class AlarmService extends Service {
public IBinder onBind(Intent intent) {
return null;
}
public void onCreate() {
// 只在创建时执行一次
}
public void onStart(Intent intent, int startId) {
// 可执行多次
Toast.makeText(this, "hello 土豆", Toast.LENGTH_LONG).show();
}
}
Xml代码
1. < application android:icon="@drawable/icon" android:label="@string/app_name">
2. < activity android:name="AlarmActivity" android:label="@string/app_name">
3. < intent-filter>
4. < action android:name="android.intent.action.MAIN" />
5. < category android:name="android.intent.category.LAUNCHER" />
6. < /intent-filter>
7. < /activity>
8. < receiver android:name="AlarmReceiver" />
9. < service android:name="AlarmService" />
10. < /application>
更多精彩
赞助商链接