Failed to start service Intent {flg = 0x4 cmp = com.UserLogin / .BgService (has additional functions)}: not found

I am trying to start a service using Alarmmanager with pendingIntent. I am stuck with a Unable to start service Intent { flg=0x4 cmp=com.UserLogin/.BgService (has extras) }: not found

 bug that I have searched on google and searched on stackoverflow, saw some questions about this error, but these solutions don't work for me. qaru.site/questions/71326 / ... , enter the link here , please check it once.

Service class:

public class BgService extends Service {

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public void onCreate() {
        // TODO Auto-generated method stub
        super.onCreate();
    }
    @Override
    public void onStart(Intent intent, int startId) {
        // TODO Auto-generated method stub
System.out.println("OnStart");
        super.onStart(intent, startId);

    }
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // TODO Auto-generated method stub
System.out.println("OnStartcmd");
       return super.onStartCommand(intent, flags, 10);
    }
}

      

AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.UserLogin"
    android:versionCode="1"
    android:versionName="1.0" >
    <application></application>
    <service android:name="com.UserLogin.BgService" />
    <uses-library android:name="com.google.android.maps" />
    <uses-library android:name="com.google.android.maps" />

    <activity
        android:configChanges="orientation|keyboardHidden"
        android:name="com.UserLogin.MyActivity" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CALL_PHONE" /></manifest>

      

java class

 Intent myIn1tent = new Intent(UserLogin.this, BgService.class);
 pendingIntent = PendingIntent.getService(UserLogin.this, 0, myIn1tent , 0);
 AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
 long firstTime = SystemClock.elapsedRealtime();
 alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, firstTime, 30 * 1000, pendingIntent);

      

Logcat error:

03-29 14:30:47.337: W/ActivityManager(58): Unable to start service Intent { flg=0x4 cmp=com.UserLogin/.BgService (has extras) }: not found

      

+3


source to share


1 answer


Your service declaration in the manifest must be nested within an application tag like this.

<application>
<service android:name="" />
</application>

      



and yes ... how can your activity be outside your app tag ..: |

+10


source







All Articles