Hi Mark, I'm pretty unfamiliar with detecting actual Airplane mode
settings, but I do have a potential work-around for you in case you
can't get it working the way you're trying to (which, by the way,
definitely seems like the -right- way to do it). I've been checking
for network connections using code like:

ConnectivityManager cm = (ConnectivityManager)getSystemService
(Context.CONNECTIVITY_SERVICE);
if (cm.getNetworkInfo(cm.TYPE_MOBILE).isConnected()){
//stuff
}
else if(cm.getNetworkInfo(cm.TYPE_WIFI).isConnected()){
//different stuff
}

This seems to work fine in my case, but with the application I am
working on I actually care  whether the user is connected over 3G/2G
or Wifi. In your case, you probably just want to get the airplane mode
detection working, but I thought I'd mention this in case you end up
stuck. Hope it helps!

On Aug 10, 10:43 am, Mark Nuetzmann <[email protected]> wrote:
> Hi,
>
> I am trying to determine if the device is in airplanemode when my
> activity starts.  I did not see a setting that exposed this but did
> see a way to set up a broadcast receiver to be notified.  After coding
> the receiver I never see my code getting loaded or called when I put
> the device into and out or Airplane mode.  Here is the code I am using
> and the setting I placed in my app manifest.  If someone could take a
> look at let me know what I am doing incorrectly I would really
> appreciate it.
>
> thanks.
>
>         <!-- Broadcast Receiver that will process be notified of
> changes in AirplaneMode -->
>         <receiver
> android:name="com.myapplication.AirplaneModeBroadcastReceiver" >
>             <intent-filter>
>                 <action
> android:name="android.intent.action.AIRPLANE_MODE_CHANGED" />
>             </intent-filter>
>         </receiver>
>
> package com.myapplication;
>
> import android.content.BroadcastReceiver;
> import android.content.Context;
> import android.content.Intent;
> import android.util.Log;
>
> public class AirplaneModeBroadcastReceiver extends BroadcastReceiver {
>     private static final String TAG = "AirplaneMode";
>
>     @Override
>     public void onReceive(Context ctx, Intent intent) {
>         Log.d(TAG, "onReceive");
>         // Do something...
>     }
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to