UI なしでアプリを作成したいのですが、サービス アプリケーションとして動作するはずです。アプリで起動完了イベントを使用しました。アプリを 2.3(Gingerbread) バージョンで実行すると、適切に動作しますが、Jellybean では動作しません。バージョン.しかし、アクティビティでアプリを実行すると、両方のバージョンで適切に動作します.解決策を教えてください.
AndroidManifest ファイル。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bootreceivecheck"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name="com.home.BootReceiver.BootCompleteReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
クラスファイル。
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class BootCompleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
try
{
Toast.makeText(context, "Mobile Boot Completed", Toast.LENGTH_LONG).show();
}catch(Exception ex)
{
Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}
}