編輯:關於Android編程
package com.imooc.intentservicetest; import android.app.IntentService; import android.content.Intent; public class MyIntentService extends IntentService { /** * Creates an IntentService. Invoked by your subclass's constructor. * * @param name Used to name the worker thread, important only for debugging. */ public MyIntentService(String name) { super(name); } public MyIntentService() { super(MyIntentService); } @Override protected void onHandleIntent(Intent intent) { } }
@Override protected void onHandleIntent(Intent intent) { }
package com.imooc.intentservicetest; import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = null; for (int i = 0; i < 10; i++) { intent = new Intent(this, MyIntentService.class); intent.putExtra(xys, + i); startService(intent); } } }
05-13 17:14:53.515 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent0 05-13 17:14:55.528 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent1 05-13 17:14:57.540 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent2 05-13 17:14:59.544 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent3 05-13 17:15:01.556 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent4 05-13 17:15:03.569 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent5 05-13 17:15:05.570 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent6 05-13 17:15:07.574 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent7 05-13 17:15:09.577 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent8 05-13 17:15:11.581 19991-20011/com.imooc.intentservicetest D/xys﹕ onHandleIntent9
一丶演示 二丶創建MusicService服務這裡貼出了後面涉及到的部分代碼 /** * 實現功能: * 1、點擊列表上的某首歌播放 * 2、點擊播放
本文實例講述了Android編程基於Contacts讀取聯系人的方法。分享給大家供大家參考,具體如下:Android Contacts簡介:這裡介紹安卓通訊錄數據庫。包括
ListView 簡介ListView 是安卓裡常用的控件, 本文介紹一下常用用法,以及優化等方法1、改寫activity_main.xml<LinearLayou
今天我們一起來探討下安卓中BroadcastReceiver組件以及詳細分析下它的兩種注冊方式。BroadcastReceiver也就是“廣播接收者”的意思,顧名思義,它