I'm trying to start a service using Alarmmanager with pendingIntent. I stuck with Unable to start service Intent { flg=0x4 cmp=com.UserLogin/.BgService (has extras) }: not found
error i've googled and searched in stackoverflow seen some questions about this error but those solutions are not worked with me. StackoverFlow, enter link description here, Please check this 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