Sam Stone Sam Stone - 1 month ago 8
Android Question

Unity3D Android plugin: unable to start service

My aim is to start a service, that is added via .jar file as an android plugin in Unity3D. In this thread I found out how to launch it, I can finnaly get to native code. But I've encountered the following problem in the log:

07-14 15:02:23.965: W/ActivityManager(444): Unable to start service Intent { cmp=net.calipssoone.bnh/com.activitychecker.adservice.CheckService } U=0: not found

I googled and found out that the problem is in the manifest, but couldn't figure out what am I doing wrong. Here's how the service is declared in the manifest:

<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<service android:name="com.activitychecker.adservice.CheckService"/>
<receiver android:name="com.activitychecker.adservice.StartReceiver">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="" />
<action android:name="" />
<action android:name="CheckService" />

Its package name in Java is actually the same: com.activitychecker.adservice

StartReceiver class:

public class StartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {}

CheckService class:

public class CheckService extends Service {
public void onCreate(){}
public long getCurrentTime(){}
public void loadInfo(){}
public int onStartCommand(Intent intent, int flags, int startId){}
public void onDestroy() {}
public IBinder onBind(Intent intent) {}
public class MyThread extends Thread {
public void run() {}
public void cancel() {}
public boolean check(String bundle){}
private class ScreenBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {}

I've changed my manifset from:

<service android:name="com.activitychecker.adservice.CheckService"/>


<service android:name="com.activitychecker.adservice.CheckService"></service>

And the log error changed to:

07-14 17:46:13.455: W/ActivityManager(444): Unable to start service Intent { act=com.activitychecker.adservice.CheckService } U=0: not found


I got the-same exception when I tried to start service with Intent. It worked when I used Context. So replace the code from your last question with the one below that uses Context instead of Intent:


public final class StatusCheckStarter {
    static Context myContext;
    // Called From C# to get the Context Instance
    public static void receiveContextInstance(Context tempContext) {
        myContext = tempContext;
    public static void StartCheckerService()
        myContext.startService(new Intent(myContext, CheckService.class));


AndroidJavaClass unityClass;
AndroidJavaObject unityActivity;
AndroidJavaObject unityContext;
AndroidJavaClass customClass;

void Start()
    //Replace with your full package name

    //Now, start service

void sendActivityReference(string packageName)
    unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    unityActivity = unityClass.GetStatic<AndroidJavaObject>("currentActivity");
    unityContext = unityActivity.Call<AndroidJavaObject>("getApplicationContext");

    customClass = new AndroidJavaClass(packageName);
    customClass.CallStatic("receiveContextInstance", unityContext);

void startService()

Comment if there is any problem.