Unable to find explicit activity class when trying to start a Service Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Unable to find explicit activity class when trying to start a Service without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have the error when I try to get values of class to other class. I search on StackOverFlow and try many methods before asking this question. I think the problem is my class extends from Services.

This is full error in log:

Unable to find explicit activity class {kr.co.composer.callrecord/kr.co.composer.callrecord.recorder.CallRecordService}; have you declared this activity in your AndroidManifest.xml?`

My code to set values:

public class ConfigurationActivity extends AppCompatActivity {
    btnSaveURL.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String textURL = serverUrl.getText().toString();
            Intent i = new Intent(getBaseContext(), CallRecordService.class);
            i.putExtra("textServerURL", textURL);
            startActivity(i);
        }
    });

And in class CallRecordServices.java:

public class CallRecordService extends Service {
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        serverURL = intent.getStringExtra("textServerURL");
        return super.onStartCommand(intent, flags, startId);
    }

Finally, this is file Manifest.xml:

<application>
    <service android:name="kr.co.composer.callrecord.recorder.CallRecordService"></service>
</application>

Answer

You are calling startActivity(i); but you need to call startService(i); instead.

We are here to answer your question about Unable to find explicit activity class when trying to start a Service - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji