2

尝试使用 Android 2.3.3 项目中另一个服务的意图启动服务时出现错误。错误是:Unable to start service with Intent{ act=(class name) cmp=(class name)/.(android name) }: java.lang.IllegalArgumentException:provider==null

方法调用:

private void startLocationService(){
    intent = new Intent("com.example.Android.LocationService");
    intent.setClass(MainService.this.getApplicationContext(), LocationService.class);
    startService(intent);
}

显现:

<service android:name=".LocationService">
        <intent-filter>
            <action android:name="com.example.Android.LocationService"/>
        </intent-filter>
    </service>
</application>
4

2 回答 2

0

问题是 LocationService.class 中的提供者吗?

于 2012-04-29T04:49:41.427 回答
0

你可以在你的调试中设置一个断点,LocationService.onCreate()看看它是否可以去那里。也许问题不是你在这里给出的。

附言。

如果只需要使用显式 Intent(应用程序内部使用),那么actionJava 代码和 Manifest 的部分都是多余的。

于 2012-04-29T05:27:59.403 回答