在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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...