I trying to make a project, I have one activity and one service from diferent package. The both package I put in one project.
I put the activity in : com.idris.activity, and I put the Service in : com.idris.activity.service
I try to call MyService from a button’s listener in MyActivity like this :
Intent myIntent = new Intent(getApplicationContext(), MyService.class);
myIntent.putExtra("extraData", "somedata");
startService(myIntent);
application’s manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="idris.parental.monitor"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyActivity"
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:name=".MyService"
android:enabled="true" />
</application>
</manifest>
MyService can’t launch, what shuld I do?
Use this in your manifest:
Make sure your are using correct
package nameforserviceinmanifestfile. IfMyService.javafile is incom.idris.activity.servicepackage than use: