Although I know that there are some answers there already, I do not quite understand them, since I am only a beginner in programming on Android. I tried to instantiate my receiver using the following code:
<receiver
android:name="com.example.android.exampleapp.MainActivity$NetworkChangeReceiver"
android:enabled="true"
android:label="NetworkChangeReceiver">
<intent-filter>
<action android:name="android.net.wifi.STATE_CHANGE" />
</intent-filter>
</receiver>
but it didn’t work. Latitude says:
java.lang.RuntimeException:
Unable to instantiate receiver com.example.android.exampleapp.MainActivity$NetworkChangeReceiver:
java.lang.InstantiationException:
class com.example.android.exampleapp.MainActivity$NetworkChangeReceiver has no zero argument constructor
Part of my code in MainActivity.java is shown below:
public class NetworkChangeReceiver extends BroadcastReceiver {
}
I know this question may seem easy, but I seriously don’t know how to resolve this error. I read this one (which I think is invalid - I don't have an empty constructor) and many other online lessons, but I still can't get it. Any help would be appreciated :)
user5404864