IntentService を使用してデータをダウンロードしています。私の IntentService クラスの定義は次のとおりです。
public class DownloadService extends IntentService{
super("DownloadService");
@Override
protected void onHandleIntent(Intent intent) {
//download tasks...
}
}
AndroidManifest.xml:
<appilcation>
<service android:name="DownloadService"/>
..
..
..
</application>
LauncherActivity.java:
@Override
public void onCreate(Bundle savedInstanceState) {
..
..
..
Intent dwnldService = new Intent(this, DownloadService.class);
startService(dwnldService);
}
しかし、まだこのエラーが発生しています:
08-13 08:57:09.416: E/AndroidRuntime(942): FATAL EXCEPTION: main
08-13 08:57:09.416: E/AndroidRuntime(942): java.lang.RuntimeException: Unable to instantiate service com.app.android.DowloadService: java.lang.InstantiationException: can't instantiate class com.app.android.DowloadService; no empty constructor
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.access$1600(ActivityThread.java:123)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.os.Looper.loop(Looper.java:137)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.reflect.Method.invokeNative(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.reflect.Method.invoke(Method.java:511)
08-13 08:57:09.416: E/AndroidRuntime(942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-13 08:57:09.416: E/AndroidRuntime(942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-13 08:57:09.416: E/AndroidRuntime(942): at dalvik.system.NativeStart.main(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): Caused by: java.lang.InstantiationException: can't instantiate class com.app.android.DowloadService; no empty constructor
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.Class.newInstanceImpl(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.Class.newInstance(Class.java:1319)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)