This is how my MainActivity and RecorderService Java class files looks like. I'm adding the AndroidManifest file too.
MainAcitivity.java
protected void onCreate(Bundle savedInstanceState) {
btnSendSOS.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendSMS();
Intent intent = new Intent(getBaseContext(), RecorderService.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
new CountDownTimer(5000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
stopService(new Intent(getApplicationContext(), RecorderService.class));
}
}.start();
});
}
RecorderService.java
public class RecorderService extends Service {
// Service code here
}
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:enabled="true"
android:name=".RecorderService" />
</application>
I have added the service to the Manifest file. But still I'm getting the error: android.content.ActivityNotFoundException: Unable to find explicit activity class {.RecorderService}; have you declared this activity in your AndroidManifest.xml?
Please help me out. Thanks in advance