سؤال

android Airplane mode not showing logs

my code is as below

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) {
        }
    }
};

}

I just turned on Airplan mode and turned off not getting my log receicer

هل كانت مفيدة؟

المحلول 2

Sometime we should think outside box :D :P

I was connected my device through wifi and testing, when I was enabling Airplane mode it was getting disconnected so I was not getting logs, The code is fine and its works as I needed

نصائح أخرى

like

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top