2013-04-06 40 views
-2

我需要检查值是否为-1。我遇到了一些我编译的源代码的问题,我不知道如何解决here的问题。需要帮助检查值是否为-1

我知道我需要实现:

if(wifiManager.addNetwork(conf) == -1) { 
    // Insert code to handle the failure here. 
} else { 
    // The rest of your code for the 'success' case here! 
} 

,但我不知道我应该插入处理故障。

+0

在发布问题时,您不应该认为任何人都知道任何事情,所以您应该尽可能清楚地询问任何事情! – 2013-04-06 02:28:38

+1

真的吗?这个问题显示了对Java基础知识的完全缺乏。您应该立即停止编码,并阅读Oracle Java教程...或任何良好的Java教科书。 – 2013-04-06 02:28:47

+1

StackExchange不能代替阅读课本/做教程,参加你的讲座。 – 2013-04-06 02:42:43

回答

3

您可以通过在if语句wifiManager.addNetwork(conf);结果比较做...

if(wifiManager.addNetwork(conf) == -1) { 
    // Insert code to handle the failure here. 
} else { 
    // The rest of your code for the 'success' case here! 
} 

我假设你用Android's WiFiManager工作。

+0

我是 - 我遇到以下问题: http://stackoverflow.com/questions/15843824/issues-passing-data-from-nfc-tag-reader-to-wifi-manager – 2013-04-06 03:07:23

+0

如果我被要求检查它是否返回-1,如果这是用log.d完成的? – 2013-04-06 03:15:14

+0

我只是不知道,如果我理解的用户问题“是否wifiManager.addNetwork(conf);返回-1” 我真的不知道我被问 – 2013-04-06 03:16:05