java service 实例化,无法实例化服务service.FetchAddressIntentService:java.lang.IllegalAccessException:不允许访问构造函数...

我的清单文件中有错误。

service.FetchAddressIntentService没有默认的构造函数

所以我在服务类中创建了如下构造函数。

现在我越来越异..

任何建议?

08-12 21:27:36.568 20148-20148/com.sunil.location.mylocation E/AndroidRuntime﹕ FATAL EXCEPTION: main

Process: com.sunil.location.mylocation, PID: 20148

java.lang.RuntimeException: Unable to instantiate service service.FetchAddressIntentService: java.lang.IllegalAccessException: access to constructor not allowed

at android.app.ActivityThread.handleCreateService(ActivityThread.java:2570)

at android.app.ActivityThread.access$1800(ActivityThread.java:139)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:136)

at android.app.ActivityThread.main(ActivityThread.java:5086)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.IllegalAccessException: access to constructor not allowed

at java.lang.Class.newInstanceImpl(Native Method)

at java.lang.Class.newInstance(Class.java:1208)

at android.app.ActivityThread.handleCreateService(ActivityThread.java:2567)

at android.app.ActivityThread.access$1800(ActivityThread.java:139)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:136)

at android.app.ActivityThread.main(ActivityThread.java:5086)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:515)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

at dalvik.system.NativeStart.main(Native Method)

08-12 21:32:36.611 20148-20148/com.sunil.location.mylocation I/Process﹕ Sending signal. PID: 20148 SIG: 9

FetchAddressIntentService

public class FetchAddressIntentService extends IntentService {

private static final String TAG = "fetch-address-intent-service";

private static final String TAG = FetchAddressIntentService.class.getSimpleName();

/**

* The receiver where results are forwarded from this service.

*/

protected ResultReceiver mReceiver;

/**

* This constructor is required, and calls the super IntentService(String)

* constructor with the name for a worker thread.

*/

FetchAddressIntentService(){

super(TAG);

}

public FetchAddressIntentService(String name) {

//Give the class name to worker thread

super(TAG);

}

............

}

清单

package="com.sunil.location.mylocation" >

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

android:name=".MainActivity"

android:label="@string/app_name" >

android:exported="false"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值