So i want to make an android app to monitor incoming data. Know how much data each network (Wifi,4g) consumes. I am currently using Xamarin.Android and i'm pretty new to android. I study comp sci in college and have had a year's worth of experience using C# (although i haven't really coded in a year) and SQL.

I have worked out how to get which network is in use, but i am not able to make the Broadcastreceiver() for detecting network change to work. The only solutions i have found are in Java which makes it a little harder. I have translated most of the java solutions and this is what i've come to:

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Net;

namespace ProjectData
{
    [BroadcastReceiver()]
    public class NetworkReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            ConnectivityManager connectivityManager = (ConnectivityManager) 
   context.GetSystemService(Context.ConnectivityService);
            NetworkInfo activeNetInfo =connectivityManager.ActiveNetworkInfo;

            if (activeNetInfo != null)
                Toast.MakeText(context, "Active Network Type : " + activeNetInfo.TypeName, ToastLength.Short).Show();

        }
    }
}

```

Now my main problem is how to use it. This is what i've been trying so far :

```
public void Network()
        {
            NetworkReceiver networkReceiver = new NetworkReceiver();
            Intent intent = new Intent(this, networkReceiver.Class);

            RegisterReceiver(networkReceiver, new IntentFilter(ConnectivityManager.ConnectivityAction));
        }

```

I haven't been able to test it because i get this error :

Tag < receiver > attribute name has invalid character ' '.

For line 10 :

```
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /></intent-filter></receiver>

```

This is the whole manifest :

```
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ProjectData.ProjectData" android:versionCode="1" android:versionName="1.0">
  <!--suppress UsesMinSdkAttributes-->
  <uses-sdk android:minSdkVersion="21" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
  <uses-permission android:name="android.permission.INTERNET"></uses-permission>
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <application android:allowBackup="true" android:label="@string/app_name" android:name="android.app.Application" android:icon="@drawable/dataicon" android:debuggable="true">
    <receiver android:name=".NetworkReceiver"> android:exported=true
      <intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE" /></intent-filter></receiver>
    <receiver android:name="md5f626beda2f87a7aeee80e4f58cdf3b35.NetworkReceiver" />
    <activity android:icon="@drawable/dataicon" android:label="ProjectData" android:name="md5f626beda2f87a7aeee80e4f58cdf3b35.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="ProjectData.ProjectData.mono.MonoRuntimeProvider.__mono_init__" />
    <!--suppress ExportedReceiver-->
    <receiver android:name="mono.android.Seppuku">
      <intent-filter>
        <action android:name="mono.android.intent.action.SEPPUKU" />
        <category android:name="mono.android.intent.category.SEPPUKU.ProjectData.ProjectData" />
      </intent-filter>
    </receiver>
  </application>
</manifest>

```

I am debugging this on my phone which runs on Android 7.0

Thanks for the help!