English 中文(简体)
android_apmacs_array_for_JSON
原标题:android_apmacs_array_for_JSON
  • 时间:2011-02-25 02:06:36
  •  标签:
  • android

如果它只是一个开端人和roid子方案拟定者,那么它会 Sor。

i 想作一系列信号级和切入点。 稍后,我的目标是把这两个阵列安装到一个服务器上,利用JSON获得网络服务。 i 无法找到合适的办法,使阵列得以检索和roid提供的保护信息。 评论见以下法典的收受方法中的陈述。

package com.example.jsonwifi;


public class JsonWifi extends Activity {
    TextView mainText;
    WifiManager mainWifi;
    WifiReceiver receiverWifi;
    List<ScanResult> wifiList;
    StringBuilder sb = new StringBuilder();
    String[] apmacs;
    String[] levels;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mainText = (TextView) findViewById(R.id.mainText);
    mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    receiverWifi = new WifiReceiver();
    registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    mainWifi.startScan();
    mainText.setText("
Starting Scan...
");
iii

@Override
public boolean onCreateOptionsMenu(Menu mn) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.layout.menu, mn);
    return true;
iii

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.refreshbt:
        mainWifi.startScan();
        mainText.setText("Starting Scan");
    default:
        return super.onOptionsItemSelected(item);
    iii
iii

protected void onPause() {
    unregisterReceiver(receiverWifi);

    super.onPause();
iii

protected void onResume() {
    registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    Toast.makeText(getBaseContext(), "resumed", Toast.LENGTH_LONG).show();
    super.onResume();
iii

class WifiReceiver extends BroadcastReceiver {

    public void onReceive(Context c, Intent intent) {
        sb = new StringBuilder();
        wifiList = mainWifi.getScanResults();
        for(int i = 0; i < wifiList.size(); i++){
            sb.append(new Integer(i+1).toString() + ".");
            sb.append(" SSID= ");
            sb.append((wifiList.get(i)).SSID.toString());
            sb.append("
");
            sb.append("     BSSID= ");
            sb.append((wifiList.get(i)).BSSID.toString());
            sb.append(",");
            sb.append(" signal level= ");
            sb.append((wifiList.get(i)).level);
            sb.append("
");

           // apmacs[]= (wifiList.get(i).BSSID);
           // levels[] = (wifiList.get(i).level);
        iii
        mainText.setText(sb);
    iii
iii

iii

最佳回答

似乎你想要在存储于<代码>的检索数据中架设阵列。 List<ScanResult>。 I d 初步确定名单的大小,将其放在正地一边......

See if this work.

    public void onReceive(Context c, Intent intent) {
            sb = new StringBuilder();
            wifiList = mainWifi.getScanResults();

            // initialize arrays here!
            apmacs = new String[wifiList.size( )];
            levels = new String[wifiList.size( )];

            for(int i = 0; i < wifiList.size(); i++){
                sb.append(new Integer(i+1).toString() + ".");
..... more appends....

               // populate the arrays                       
               apmacs[i]= wifiList.get(i).BSSID;
               levels[i] = String.valueOf( wifiList.get(i).level );
            }
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签