首页 \ 问答 \ 如何避免在标准的Android WiFi列表中复制WiFi网络?(How to avoid duplicating of WiFi networks in standard android WiFi list?)

如何避免在标准的Android WiFi列表中复制WiFi网络?(How to avoid duplicating of WiFi networks in standard android WiFi list?)

在我的Android应用程序中,我连接到WiFi网络。 但是,例如,如果我连接到这个网络很多次,这个网络的名称很多次出现在标准的Android WiFi列表中。 我怎样才能避免这种情况?

我的代码:

String networkSSID = "test"; 
String networkPass = "pass";
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";  
conf.preSharedKey = "\""+ networkPass +"\"";
WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
wifiManager.addNetwork(conf);

我会尽快添加截图


In my android app I connect to WiFi network. But, for example, if I connect to this network plenty of times, name of this network appears in standard android WiFi list plenty of times. How can I avoid this?

My code:

String networkSSID = "test"; 
String networkPass = "pass";
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\"";  
conf.preSharedKey = "\""+ networkPass +"\"";
WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
wifiManager.addNetwork(conf);

I'll add a screenshot as soon as possible


原文:https://stackoverflow.com/questions/20541387
更新时间:2022-04-02 11:04

最满意答案

F#Powerpack中的BigRational定义如下:

   [<CustomEquality; CustomComparison>]
   [<StructuredFormatDisplay("{StructuredDisplayString}N")>]
   type BigRational =
       | Z of BigInteger
       | Q of BigRationalLarge

BigRationalLarge定义为:

[<CustomEquality; CustomComparison>]
type BigRationalLarge = 
    | Q of BigInteger * BigInteger

要以1000精度打印BigInt ,请执行以下操作:

let factorial n = Seq.fold ( * ) 1I [1I .. n]

printf "Factorial of 1000 is %A" (factorial 1000I) 

这里开始

这里查看 BigRationalLarge类型:

有许多方法可以将其转换为不同的类型进行打印:

   static member ToDouble(n:BigRational) = 
        match n with
        | Z z -> ToDoubleI z
        | Q q -> BigRationalLarge.ToDouble q

    static member ToBigInt(n:BigRational) = 
        match n with 
        | Z z -> z
        | Q q -> BigRationalLarge.integer q 

    static member ToInt32(n:BigRational) = 
        match n with 
        | Z z -> ToInt32I(z)
        | Q q -> ToInt32I(BigRationalLarge.integer q )

转换为double看起来像这样:

   static member ToDouble (Q(p,q)) = 
        ToDoubleI p / ToDoubleI q

将其打印为分子和分母组合的默认方式:

   override n.ToString() =
        let (Q(p,q)) = n 
        if q.IsOne then p.ToString() 
        else p.ToString() + "/" + q.ToString()

这些都不能帮助我们获得更高的精确度。 指定要打印的小数位数时无法打印它。

所以回答你的问题:

您可以使用BigRational的两个BigInt部分创建一个打印所需值的函数,或者您可以编写一个全新的类型来为您执行此操作,但现在没有类似的东西。


BigRational in the F# Powerpack is defined like this:

   [<CustomEquality; CustomComparison>]
   [<StructuredFormatDisplay("{StructuredDisplayString}N")>]
   type BigRational =
       | Z of BigInteger
       | Q of BigRationalLarge

Where a BigRationalLarge is defined as:

[<CustomEquality; CustomComparison>]
type BigRationalLarge = 
    | Q of BigInteger * BigInteger

To Print a BigInt with 1000 precision do something like this:

let factorial n = Seq.fold ( * ) 1I [1I .. n]

printf "Factorial of 1000 is %A" (factorial 1000I) 

Taken from here.

Looking at the BigRationalLarge type here:

There are a number of ways to convert it to a different type to print:

   static member ToDouble(n:BigRational) = 
        match n with
        | Z z -> ToDoubleI z
        | Q q -> BigRationalLarge.ToDouble q

    static member ToBigInt(n:BigRational) = 
        match n with 
        | Z z -> z
        | Q q -> BigRationalLarge.integer q 

    static member ToInt32(n:BigRational) = 
        match n with 
        | Z z -> ToInt32I(z)
        | Q q -> ToInt32I(BigRationalLarge.integer q )

The conversion to a double looks like this:

   static member ToDouble (Q(p,q)) = 
        ToDoubleI p / ToDoubleI q

The default way of printing it as a numerator and denominator combination:

   override n.ToString() =
        let (Q(p,q)) = n 
        if q.IsOne then p.ToString() 
        else p.ToString() + "/" + q.ToString()

None of that really helps us get more precision. There is no way to print it while specifying the number of decimal places to print.

So to answer your question:

You could make a function that prints the values you want, using the two BigInt parts of a BigRational or you could write an entirely new type to do this for you, but there isn't anything like that right now.

相关问答

更多
  • F# float只是System.Double的简写。 在这种情况下,您可以使用BitConverter.DoubleToInt64Bits方法有效地(并安全地! )将F# float值“ int64 ”为int64 ; 这很有用,因为它避免了像John在评论中提到的那样分配一个byte[] 。 您可以使用一些简单的按位运算从该int64获取指数和有效数。 正如约翰所说,你可能最好通过简单检查相对准确性。 对于许多用例而言,它可能是最快的解决方案并且“足够接近”(例如,检查迭代求解器是否已融合到解决方案上) ...
  • 总结对OP问题的评论。 AC库可能是大型浮点库的最佳解决方案。 GMP声称是最快的免费图书馆,自1991年以来一直通过装配进行优化。 将此 Delphi包装器用于GMP库。 为了以更快的速度和合理的成本/精力,CUDA / GPU解决方案可以完成这项工作。 有工作正在进行,但我找不到最终的解决方案。 To summarize the comments to the OP's question. A C library is probably the best solution for a big float ...
  • F#Powerpack中的BigRational定义如下: [] [] type BigRational = | Z of BigInteger | Q of BigRationalLarge 将BigRationalLarge定义为: [
  • 乘以100,精确打印0。 int main () { double f =3.14159; std::cout.precision(0); std::cout << std::fixed << f*100 << '\n'; return 0; } Multiply by a 100 and print with precision 0. int main () { double f =3.14159; std::cout.precision(0); std::cout << ...
  • http://code.google.com/p/gwt-math/上有GWT-MATH库。 但是,我警告你,它是一个java-> javascript自动转换java.BigDecimal(实际上是旧的com.ibm.math.BigDecimal)的GWT jsni覆盖。 它可以工作,但速度并非如此。 (不是精益,它会在你的项目中保持良好的70k)。 在我的工作场所,我们正在研究一个固定点的简单小数点,但没有什么值得发布的。 :( There is the GWT-MATH library at htt ...
  • 你可以做这样的事情(虽然有些人声称它违反了严格别名规则): unsigned int func(unsigned int n) { float x = *(float*)&n; x *= 2; return *(unsigned int*)&x; } void test(float x) { unsigned int n = *(unsigned int*)&x; printf("%08X\n",func(n)); } 在任何情况下,您都必须声明float的大小等 ...
  • 我修改了代码以在四舍五入的值后立即打印每个结果的确切值: Float = 0.9 0.89999997615814208984375 Double = 0.8999999999999999 0.899999999999999911182158029987476766109466552734375 双重结果比浮点结果更接近0.9。 这些是在任何额外计算中都会使用的值。 打印输出的差异是Float和Double toString方法的结果。 每种方法都旨在产生最短的结果,即在转换回相应的类型时,会产生原始值。 ...
  • 这取决于您使用的客户端库。 大多数似乎需要将字符串或[]字节作为参数传递。 检查您正在使用的库的文档。 我会怀疑任何接受big.Float。 要转换为字符串,我可能会通过fmt使用标准的Go字符串格式。 It depends on the client library you are using. Most seem to require strings or []byte to be passed as arguments. Check the docs for the library you are u ...
  • 从Python文档: 注意对于浮点数, round()的行为可能会令人惊讶:例如, round(2.675, 2)给出2.67而不是预期的2.68 。 这不是一个错误:这是因为大多数小数部分不能完全表示为浮点数。 有关更多信息,请查看每个程序员应该知道的关于浮点运算的内容 。 如果您不了解计算机如何处理浮点数,请不要使用此代码 。 如果你知道自己遇到了什么麻烦: fn approx_equal(a: f64, b: f64, decimal_places: u8) -> bool { let fac ...
  • 不是直接的。 我最终的计划是使分布类型参数化,这也允许Float32参数,但还有一段时间了。 与此同时,还有未导出的φ ,它给出了你想要的结果: Distributions.φ(x) - pdf(Normal(), x_small) Not directly. My eventual plan is to make Distribution types parametric, which would also allow for Float32 arguments, but that is a while ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)