AIRPLANE_MODE操作未收到

时间:2014-04-28 12:29:34

标签: android android-intent android-broadcast

android飞机模式没有显示日志

我的代码如下

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    IntentFilter intentFilter = new IntentFilter(ACTION_AIRPLANE_MODE);
    registerReceiver(mBroadcastReceiver, intentFilter);
    // AppRater.app_launched(new WeakReference<Activity>(this));
}

@Override
protected void onDestroy() {
    super.onDestroy();
    unregisterReceiver(mBroadcastReceiver);
}

private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("Mass", "Action " + intent.getAction());
        if (intent.getAction().equals(ACTION_AIRPLANE_MODE)) {
            mHandlerRedrawUI.sendEmptyMessage(UPDATE_VISIBILITY);
        }
    }
};

private static final int UPDATE_VISIBILITY = 1;
private static final String ACTION_AIRPLANE_MODE = "android.intent.action.AIRPLANE_MODE";
Handler mHandlerRedrawUI = new Handler() {
    public void handleMessage(android.os.Message msg) {
        if (msg.what == UPDATE_VISIBILITY) {
        }
    }
};

}

我刚打开Airplan模式并关闭没有收到我的日志接收器

2 个答案:

答案 0 :(得分:0)

<receiver android:name="com.example.Bootreciever">
 <intent-filter>
     <action android:name="android.intent.action.AIRPLANE_MODE"/>
 </intent-filter>

答案 1 :(得分:0)

有时我们应该考虑外框:D:P

我通过wifi和测试连接了我的设备,当我启用飞行模式时,它正在断开连接,所以我没有得到日志,代码很好,它的工作正如我所需