PendingIntent/IntentService java.lang.InstantiationException: java.lang.Class<XX.MainActivity$PluginResultsService> не иAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Гость
 PendingIntent/IntentService java.lang.InstantiationException: java.lang.Class<XX.MainActivity$PluginResultsService> не и

Сообщение Гость »

На Android 12.
Я использую этот пример: [https://github.com/termux/termux-app/wi ... e-examples]
Мой код:

Код: Выделить всё

  ...
PendingIntent pendingIntent = PendingIntent.getService(MainActivity.this, executionId, pluginResultsServiceIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
intent.putExtra(RUN_COMMAND_SERVICE.EXTRA_PENDING_INTENT, pendingIntent);

try {
// Send command intent for execution
Log.d(LOG_TAG, "Sending execution command with id " + executionId+ " / "+PluginResultsService.EXTRA_EXECUTION_ID);
startService(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "Failed to start execution command with id " + executionId + ": " + e.getMessage());
}
}

public class PluginResultsService extends IntentService {

public static final String EXTRA_EXECUTION_ID = "execution_id";

public static final String PLUGIN_SERVICE_LABEL = "PluginResultsService";

public PluginResultsService(){
super(PLUGIN_SERVICE_LABEL);
}

@Override
protected void onHandleIntent(@Nullable Intent intent) {
Log.d(LOG_TAG, "In onHandler");
if (intent == null) return;

Log.d(LOG_TAG, PLUGIN_SERVICE_LABEL + " received execution result");

final Bundle resultBundle = intent.getBundleExtra(TERMUX_SERVICE.EXTRA_PLUGIN_RESULT_BUNDLE);
if (resultBundle == null) {
Log.e(LOG_TAG, "The intent does not contain the result bundle at the \"" + TERMUX_SERVICE.EXTRA_PLUGIN_RESULT_BUNDLE + "\" key.");
return;
}

final int executionId = intent.getIntExtra(EXTRA_EXECUTION_ID, 0);

Log.d(LOG_TAG, "...");
}

}
В файле манифеста я добавил: Когда вызывается мой IntentService, мое приложение связывается с logcat:
2024-03-17 09:33:34.989 938-938 Layer Surfaceflinger I id=7260 Destroyed Surface(name=8426a6f eu.eduphone.manage/eu.eduphone.MainActivity)/@0x85de1fe - анимация-привязка start_reveal#0
17.03.2024 09: 33:36.112 15759-15759 ViewRootIm...nActivity] eu.eduphone.manage I Указатель ViewPostIme 0
2024-03-17 09:33:36.225 15759-15759 ViewRootIm...nActivity ] eu.eduphone.manage I указатель ViewPostIme 1
2024-03-17 09:33:36.251 938-938 BufferQueueProducer Surfaceflinger I eu.eduphone.manage/eu.eduphone.MainActivity$_15759 #0 очередьBuffer: fps=0,52 dur=7639,82 max=7390,75 min=49,89
2024-03-17 09:33:39.724 1460-5753 ActivityManager system_server D Получено намерение SERVICE 0xd98cfe7 Key{startService pkg=eu.eduphone.manage Intent=cmp=eu.eduphone.manage/eu.eduphone.MainActivity$PluginResultsService flags=0x44000000 u=0} requestCode=1000 из uid 10396
2024- 03-17 09:33:39.734 15759-15759 AndroidRuntime eu.eduphone.manage E ФАТАЛЬНОЕ ИСКЛЮЧЕНИЕ: main
Процесс: eu.eduphone.manage, PID: 15759
java.lang.RuntimeException: невозможно создать service eu.eduphone.MainActivity$PluginResultsService: java.lang.InstantiationException: java.lang.Class не имеет конструктора с нулевым аргументом
в android.app.ActivityThread.handleCreateService(ActivityThread.java) :5035)
Есть идеи о причине?

Подробнее здесь: https://stackoverflow.com/questions/781 ... lang-class
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»