0

我创建了一个名为 MyLibrary 的 Android 库项目,它遵循AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="test.myservice"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <service android:name="mytest.myservice.RemoteService" android:exported="true">
            <intent-filter >
                <action android:name="MYSERVICE"/>
            </intent-filter>
        </service>
    </application>

</manifest>

创建库项目后,我将此库项目的引用添加到名为 TestMyLibrayApp 的应用程序中。我正在从我的应用程序启动服务,如下所示。

Intent playerservice = new Intent();
playerservice.setAction("MYSERVICE");
getBaseContext().bindService(playerservice,conn , Service.BIND_AUTO_CREATE);

其中conn是服务连接对象。现在的问题是服务没有开始。谁能建议我错在哪里?

4

1 回答 1

1

您需要将该<service>部分添加到 TestMyLibraryApp 的清单中。未使用库的清单。

于 2012-12-21T08:54:36.130 回答