android - Why my application crash? I am using service -
i made service every 5 sec set on screen tag (i think name of this). when create boot needs set tag on screen says app crashed. why? code: android manifest:
<uses-permission android:name="android.permission.receive_boot_completed"/> <receiver android:name="com.yuvalfatal.mybroadcastreceiver" > <intent-filter> <action android:name="android.intent.action.boot_completed" /> </intent-filter> </receiver> <service android:enabled="true" android:name="com.yuvalfatal.myservice"/>
broadcastreceiver:
bundle com.yuvalfatal.ineedhelp; import java.util.timer; import java.util.timertask; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; public class mybroadcastreceiver extends broadcastreceiver { @override public void onreceive(final context arg0, intent arg1) { timer timer = new timer(); timer.schedule(new timertask() { public void run() { intent startserviceintent = new intent(arg0, myservice.class); arg0.startservice(startserviceintent); } }, 0, 5000); } }
intentservice:
package com.yuvalfatal.ineedhelp; import android.app.intentservice; import android.content.intent; import android.util.log; public class myservice extends intentservice { private static final string tag = "com.yuvalfatal.ineedhelp"; public myservice(string name) { super(name); // todo auto-generated constructor stub } @override protected void onhandleintent(intent intent) { // todo auto-generated method stub log.i(tag, "intent service started"); } }
i think (yep, magician , have great intuition :) service constructor should default:
public class myservice extends intentservice { ... public myservice() { // default constructor! without params! super("myservice"); // or string } ... }
other code looks normal
android android-layout android-intent android-service
No comments:
Post a Comment