没有GUI的Android应用程序

Vig*_*ala 2 android broadcastreceiver android-manifest android-wifi

我一直在使用广播接收器开发一个没有UI的简单应用程序.

该应用程序不包含任何活动.

我已经给了必要的权限.

我从这个网址获取了代码:http://developerandro.blogspot.in/2013/09/check-internet-connection-using.html

当我点击更改wifi状态时,该应用程序显示吐司"未连接到互联网".它工作正常.

但我的问题是我的清单文件中注册了一项我没有的活动.所以我从清单中删除了这些行.然后没有显示吐司,我也检查了日志.改变wifi状态时没有输出.

为什么会这样?请帮帮我们......

这是清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.broadcast_internetcheck"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.broadcast_internetcheck.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name="com.example.broadcast_internetcheck.NetworkChangeReceiver"
            android:label="NetworkChangeReceiver" >
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
            </intent-filter>
        </receiver>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

这是我的Broadcastreceiver类:

public class NetworkChangeReceiver extends BroadcastReceiver{

  @Override
     public void onReceive(final Context context, final Intent intent) {

         String status = NetworkUtil.getConnectivityStatusString(context);
          /*Above line will return the status of wifi */
         Toast.makeText(context, status, Toast.LENGTH_LONG).show();

     }
}
Run Code Online (Sandbox Code Playgroud)