adb で IntentService を開始しようとすると、次のエラーが表示されます
E/AndroidRuntime( 2418): java.lang.RuntimeException: Unable to instantiate service
com.myCompany.MyPackage.Service: java.lang.InstantiationException:
com.myCompany.MyPackage.Service
通常のサービス ovre adb を開始すると、すべて正常に動作します。
adb経由でintentserviceを開始できない理由は何ですか?
public class NCService extends IntentService {
public NCService(String name) {
super(name);
// TODO Auto-generated constructor stub
}
NetworkStateReceiver nsr;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "onStartCommand", 0).show();
nsr = new NetworkStateReceiver();
return START_STICKY;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "onCreate", 0).show();
super.onCreate();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "onDestroy", 0).show();
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
}
}
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".NCService" />
<receiver android:name=".NetworkStateReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
</application>
よろしくサイモン