0

我有一个我的应用程序,其中有一个按钮调用相关库中的服务。当我单击按钮时,会显示两个 Log 语句(如果服务正在发生,我认为第二个语句不应该)。

我在服务中的 onCreate/onStartCommand 等中有日志语句,所以我知道它没有启动服务。除了我的清单没有正确地为服务制作之外,我想不出任何东西。

按钮:

public void onClick(View v) {

     Intent service = new Intent(com.test.ServiceNexus.SERVICE);
     Log.e(TAG,"Service Starting");
     startService(service);
     Log.e(TAG,"Service Failed");
}

在应用程序关闭节点内提供服务的库清单:

 <service
            android:enabled="true"
            android:persistent="true"
            android:name="com.andal.ServiceNexus"
            android:process=":ServiceProcess">
            <intent-filter>
                <action
                    android:name="com.test.ServiceNexus.SERVICE" />
            </intent-filter>
</service> 

我有一个不同的服务,它在应用程序中调用一个服务并且可以工作。该服务的申请清单:

<service android:enabled="true" android:name=".MyService"/>  
4

1 回答 1

1

清单需要在我的应用程序内部而不是在清单内部声明。此外,它的名称需要包括它来自哪里的包。

从不同的包启动服务有点帮助

于 2013-07-18T15:11:44.330 回答