Failed to start Intent service in my Android program, what's wrong?

I'm new and just starting to learn google android right now

So, I study the code after I googled, but I do not know why it cannot work well as I wish. This program consists of two java files, AlarmService.java, which contains an activity named AlarmService and AlarmService_Service.java, which contains a service called AlarmService_Service. Btw, I put it in the com.AlarmService package

Here, where I created the intent in the AlarmService activity (in AlarmService.java):

Purpose of Intent = New Intent (AlarmService.this, AlarmService_Service.class);

mAlarmSender = PendingIntent.getService (AlarmService.this, 0, intent, 0);

Button button = (button) findViewById (R.id.start_alarm); button.setOnClickListener (mStartAlarmListener);

And the code in AlarmService_Service is quite long, but in any case, I also made Toast to request text to make sure that this service works or not.

It looks like the program was unable to load AlarmService_Service. Nothing happens when I clicked a button, not even Toast, and I saw this message in LogCat:

Unable to start the Intent service {flg = 0x4 cmp = com.AlarmService / .AlarmService_Service (there are additional functions)}: not found

Honestly, I am not familiar with Android, so I keep wondering what is wrong with this code. Did I miss something? Or is it because he could not find AlarmService_Service.class?

Thanks for your great help.

+3
2

(), , <service>. AlarmService_Service AndroidManifest.xml?

+2

, PendingIntent :

PendingIntent mAlarmSender = PendingIntent.getService(AlarmService.this, 0, new Intent(AlarmService.this, AlarmService_Service.class), 0);

0

Source: https://habr.com/ru/post/1779723/


All Articles