package="com.cchen.connect"
android:versionCode="1"
android:versionName="1.0">
Java代码 package com.cchen.connect;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.util.Log;
public class ActionReceiver extends BroadcastReceiver{
static final String LOG_TAG = "ActionReceiver";
private BluetoothAdapter blueAdapter;
@Override
public void onReceive(Context context, Intent intentIn) {
Log.d(LOG_TAG, "ACTION = " + intentIn.getAction());
String action = intentIn.getAction();
if (Intent.ACTION_USER_PRESENT.equals(action) || Intent.ACTION_BOOT_COMPLETED.equals(action) )
{
blueAdapter = BluetoothAdapter.getDefaultAdapter();
if(!blueAdapter.isEnabled()){
blueAdapter.enable();
}
WifiManager wifiMgr = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
int wifiState = wifiMgr.getWifiState();
if(wifiState == WifiManager.WIFI_STATE_DISABLED)
{
wifiMgr.setWifiEnabled(true);
}
Log.d(LOG_TAG, "========== UNLOCKINTENT " + blueAdapter.isEnabled() + wifiMgr.getWifiState());
}
}
}