起動時にサービスを開始するために使用するレシーバーをインスタンス化しようとすると、Androidアプリケーションでエラーが発生しました。エラーは明らかです、それは私の受信機のクラスファイルを見つけることができません。しかし、マニフェストファイル、パッケージ、その他すべてに問題はなく、何が起こっているのかわかりません。これが私のコードです:
package dti.obd.reader;
import dti.obd.reader.service.MainService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Intent serviceIntent = new Intent(MainService.class.getName());
context.startService(serviceIntent);
}
}
そして私のマニフェストファイル:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dti.obd.reader"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".service.MainService" >
<intent-filter >
<action android:name="dti.obd.reader.service.MainService" />
</intent-filter>
</service>
<receiver android:name="dti.obd.reader.BootReceiver" >
<intent-filter >
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>
誰かがエラーを知っていますか?パッケージと名前はすべて大丈夫のようです...