How? What do u need?


Am Dienstag, 8. Oktober 2013 21:14:55 UTC+2 schrieb BearTi:
>
> Hi,
>
> I´ve a big problem with the "getScanResults()" function. I always get "0" 
> as result.
>
> Here is my Code (it´s a service):
>
>     public void onCreate() {
>>         super.onCreate();
>>         
>>         wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);
>>         sharedPreferences = 
>> PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
>>         intentScan = new IntentFilter();
>>         intentScan.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
>>         scanReceiver = new ScanReceiver();
>>         
>>         screenOnReceiver = new ScreenOnReceiver();      
>>         registerReceiver(screenOnReceiver, new 
>> IntentFilter(Intent.ACTION_SCREEN_ON));
>>         
>>         screenOffReceiver = new ScreenOffReceiver();
>>         registerReceiver(screenOffReceiver, new 
>> IntentFilter(Intent.ACTION_SCREEN_OFF));
>>     }
>>     
>>     @Override
>>     public void onDestroy () {
>>       unregisterReceiver(screenOnReceiver);
>>       unregisterReceiver(screenOffReceiver);
>>     }
>>     
>>     @Override
>>     public void onStart(Intent intent, int startId) {
>>     wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);
>>     
>> registerReceiver(scanReceiver, intentScan); 
>>     
>>     showToasts = sharedPreferences.getBoolean("checkbox_notification", 
>> true);
>>     autoSync = sharedPreferences.getBoolean("checkbox_autosync", true);
>>     if(wifiMgr.getConnectionInfo().getNetworkId() == -1) {
>>         if(wifiMgr.setWifiEnabled(true)) {
>>         
>>        if(!wifiMgr.startScan()){ 
>>        unregisterReceiver(scanReceiver);
>>        }
>> }
>> }else{
>> if(showToasts)
>> Toast.makeText(this.getApplicationContext(),R.string.toast_nochange, 
>> Toast.LENGTH_SHORT).show();
>> }
>>     }
>>
>
>>  
>
>     public class ScanReceiver extends BroadcastReceiver {
>>     @Override
>>     public void onReceive(Context context, Intent intent) {
>>     Log.d("wifi", "ScanComplete - "+intent.getAction());
>>     
>>     List<WifiConfiguration> wifiListSupplicant = 
>> wifiMgr.getConfiguredNetworks();
>>     List<ScanResult> wifiListScan = wifiMgr.getScanResults();
>>     
>>        
>>     Log.d("wifi", "LIST: "+wifiListScan.size());
>
> } } 
>
>
>
> Somebody an idea?
>
> Thanks"
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to