微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Android [JAVA]中看不到LocalWiFiOnlyHotspot的问题?

如何解决在Android [JAVA]中看不到LocalWiFiOnlyHotspot的问题?

我只想在android应用程序中获得一些帮助。在我的应用中,存在一个无法解决的问题,即我已编写了具有启用和禁用热点所需的所有权限的代码,当我在另一台设备上看到该热点时,该热点正在显示,但是该热点的图标不可见。我只想显示它。我正在与您分享代码的屏幕截图。

ScreenShot of Hotspot but not visible

Hotspot is On State

预先感谢!

 @RequiresApi(api = Build.VERSION_CODES.O)
public void turnOnHotspot() {

    try {
        if (ActivityCompat.checkSelfPermission(SendFileActivity.this,Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // Todo: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions,and then overriding
            //   public void onRequestPermissionsResult(int requestCode,String[] permissions,//                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }

        wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
            wifiManager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() {

                @Override
                public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {

                    super.onStarted(reservation);
                    hotspotReservation = reservation;
                    currentConfig = hotspotReservation.getWifiConfiguration();

                    Log.v("DANG","THE PASSWORD IS: "
                            + currentConfig.preSharedKey
                            + " \n SSID is : "
                            + currentConfig.SSID);

                    hotspotDetailsDialog();
                   // Log.e(TAG,"Current Config : "+wifiHotspot.getCurrConfig() );
                  //  Log.e(TAG,"Current Hotspot Status : "+wifiHotspot.isHotspotEnabled() );
                //    Log.e(TAG,"Hotspot Support : "+wifiHotspot.isSupported() );
                 //   Log.e(TAG,"Enable Hotspot : "+currentConfig.SSID);
                    //Log.e(TAG,"disable Hotspot : "+wifiHotspot.disableHotspot() );
                }

                @Override
                public void onStopped() {
                    super.onStopped();
                    Log.v("DANG","Local Hotspot Stopped");
                }

                @Override
                public void onFailed(int reason) {
                    super.onFailed(reason);
                    Log.v("DANG","Local Hotspot Failed to start");
                }
            },new Handler());
    } catch (Exception e) {
        e.printstacktrace();
    }
}
private void hotspotDetailsDialog()
{
    Log.e(TAG,this.getString(R.string.hotspot_details_message) + "\n" + this.getString(
            R.string.hotspot_ssid_label) + " " + currentConfig.SSID + "\n" + this.getString(
            R.string.hotspot_pass_label) + " " + currentConfig.preSharedKey);
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。