I'm trying to do a basic BroadcastReceiver that can receive the Action_BOOT_COMPLETED. Whenever I run this in the emulator, it doesn't seem like the code from the BroadcastReceiver code.
Manifest as follows:
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".BootAtStartupActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".BootAtStartupReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>
MainActivity:
package com.mfcoding.android.bootatstartup;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class BootAtStartupActivity extends Activity {
static final String TAG = "BootAtStartupActivity";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d(TAG, "onCreate");
}
}
BroadcastReceiver:
package com.mfcoding.android.bootatstartup;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class BootAtStartupReceiver extends BroadcastReceiver {
static final String TAG = "BootAtStartupReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.d(TAG, "*** onReceive ACTION_BOOT_COMPLETED");
}
Log.d(TAG, "*** onReceive");
}
}
In Logcat, I never see the Log printout for the BroadcastReceiver file. All i see in Logcat is the Activity log printout. Any ideas? I'd like to see in Logcat the Log print statements of the Broadcast Receiver class.
Link to project https://github.com/fangstar/BootAtStartup