// http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest // http://developer.android.com/guide/topics/manifest/service-element.html //AtBootCompleted hack1; protected override void onCreate(global::android.os.Bundle savedInstanceState) { // http://developer.android.com/guide/topics/ui/notifiers/notifications.html base.onCreate(savedInstanceState); ScrollView sv = new ScrollView(this); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); sv.addView(ll); var btn = new Button(this); btn.setText("wifi"); ll.addView(btn); { ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifiNetInfo != null) { if (wifiNetInfo.isConnectedOrConnecting()) { btn.setText("we are connected via WiFi"); } } if (mobileNetInfo != null) { if (mobileNetInfo.isAvailable()) { if (mobileNetInfo.isConnected()) { btn.setText(" we are connected via mobile data (GPRS, 3G, etc.)"); } } } } this.setContentView(sv); this.StartPendingAlarm(typeof(NotifyService), 1000 * 1, 0); }
public static bool isWifiConnected(Activity act) { ConnectivityManager connManager = (ConnectivityManager)act.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return(mWifi.isConnected()); }
public override int onStartCommand(Intent value0, int value1, int value2) { Log.wtf("AndroidWifiNotificationActivity", "onStartCommand"); this.ToNotification( Title: "wifi", Content: "Toggle wifi to see notifications", id: (int)java.lang.System.currentTimeMillis(), icon: android.R.drawable.star_on, uri: "http://my.jsc-solutions.net" ); #region Wifi { ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifiNetInfo != null) { if (wifiNetInfo.isConnectedOrConnecting()) { this.ToNotification( Title: "wifi!", Content: "we are connected via WiFi", id: (int)java.lang.System.currentTimeMillis(), icon: android.R.drawable.star_on, uri: "http://my.jsc-solutions.net" ); } } if (mobileNetInfo != null) { if (mobileNetInfo.isAvailable()) { if (mobileNetInfo.isConnected()) { this.ToNotification( Title: "wifi!", Content: "we are connected via mobile data (GPRS, 3G, etc.)", id: (int)java.lang.System.currentTimeMillis(), icon: android.R.drawable.star_on, uri: "http://my.jsc-solutions.net" ); } } } } #endregion this.stopSelf(); return(0); }