Я новичок в Android, и я пытаюсь использовать IntentService, и ошибка заключается в отсутствии конструктора по умолчанию Я попытался перезапустить студию Android, она не работает.
package com.example.hitesh.kuchbhi;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.NotificationCompat;
import java.util.TreeSet;
public class DisplayNotification extends IntentService {
public DisplayNotification(String name) {
super("DisplayNotification");
}
@Override
protected void onHandleIntent(Intent intent) {
// my code which even after deleting gives the same error
}
Ошибка журнала ошибок
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hitesh.kuchbhi, PID: 28899
java.lang.RuntimeException: Unable to instantiate service com.example.hitesh.kuchbhi.DisplayNotification: java.lang.InstantiationException: class com.example.hitesh.kuchbhi.DisplayNotification has no zero argument constructor
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2728)
at android.app.ActivityThread.access$1800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1368)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5233)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)