Question

I'm trying to get a bar chart that plots, in real time , the wifi received signal strength . Well i'm using a brodcastreceiver ,to get the RSSI changes, and the achartengine to plot those information .But i'm just having the bar chart for the first received data, and eiven if RSSI data is changing ,nothing happens on my chart.

EDIT

Well i guess i know why i have the first chart ,the methode getTruitonBarDataset is executing just one time ,can someone tell me how can i fix that.Thank you in advance.

This the onReceive methode from the brodcastreceiver class :

public void onReceive(Context context, Intent intent) {

            int length ;
            if(intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)){
                 List<ScanResult> results = wifi.getScanResults();
                 length=results.size();

                   Log.i("length1",length +"");
                    XYMultipleSeriesRenderer renderer = getTruitonBarRenderer(results.size());
                    myChartSettings(renderer);

                       if (mChartView == null)
                       {mChartView = ChartFactory.getBarChartView(WifiChartsRealTime.this, getTruitonBarDataset( results), renderer, Type.STACKED); 
                       layout.addView(mChartView);} 
                       else {mChartView.repaint();}  


             }


        }

Thank you in advance.

Was it helpful?

Solution

Thanks to waqaslam and this post ,its working and this is my receive method :

public void onReceive(Context context, Intent intent) {
            WifiManager wifiMan=(WifiManager)WifiChartsRealTime.this.getSystemService(Context.WIFI_SERVICE);
              wifiMan.startScan();


            if(intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)){
                 results = wifi.getScanResults();
                 length=results.size();


                   Log.i("length1",length +"");
                    XYMultipleSeriesRenderer renderer = getTruitonBarRenderer(results.size());
                    myChartSettings(renderer);




                       layout = (LinearLayout) findViewById(R.id.chart);
                       if (mChartView != null) {
                           layout.removeView(mChartView);
                        }
                       mChartView = ChartFactory.getBarChartView(WifiChartsRealTime.this, getTruitonBarDataset( results), renderer, Type.STACKED); 
                       layout.addView(mChartView, 0, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));


            }



        }`
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top