Sfoglia il codice sorgente

显示网络状态

ifengouy 2 anni fa
parent
commit
f4faa54715

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -8,6 +8,7 @@
 
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 
     <!-- 显示系统窗口权限 -->
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

+ 1 - 0
app/src/main/java/com/sunwin/visitorapp/SplashActivity.java

@@ -145,6 +145,7 @@ public class SplashActivity extends AppCompatActivity {
         permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
         permissions.add(Manifest.permission.READ_PHONE_STATE);
         permissions.add(Manifest.permission.CAMERA);
+        permissions.add(Manifest.permission.ACCESS_NETWORK_STATE);
 
     }
 

+ 2 - 0
app/src/main/java/com/sunwin/visitorapp/activity/HomeAc.java

@@ -20,6 +20,7 @@ import com.sunwin.visitorapp.fragment.HomeFr;
 import com.sunwin.visitorapp.fragment.RegTypeFragment;
 import com.sunwin.visitorapp.fragment.VisitSignFragment;
 import com.sunwin.visitorapp.utils.Constant;
+import com.sunwin.visitorapp.utils.NetUtils;
 import com.sunwin.visitorapp.utils.PopupWindowHelper;
 import com.sunwin.visitorapp.utils.SharePrefenceUtils;
 import com.sunwin.visitorapp.utils.ToastUtils;
@@ -108,6 +109,7 @@ public class HomeAc extends BaseActivity implements View.OnClickListener, RegTyp
                 finish();
                 break;
             case R.id.ImageStatus:
+                mTvNetStatus.setText(NetUtils.isConnected(this)?"正常":"未连接网络");
                 popupWindowHelper.showAsDropDown(ImageStatus);
                 break;
         }