Android: Broadcastreceiver with Achartengine ,don't display updates

前端 未结 1 1295
说谎
说谎 2021-01-24 14:45

I\'m trying to display information got from wifi scan with broadcast receiver ,into a bar chart using achartengine. Well i want to have a real time chart ,every time i receive d

相关标签:
1条回答
  • 2021-01-24 15:31

    Well i resolved this problem ,to have a eal time chart (bar chart ) ,i have to change tho my onReceive method like bellow.I hope it will help someone.

    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));
    
    
            }
    
    
    
        }`
    
    0 讨论(0)
提交回复
热议问题