Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
+ Reply
Results 1 to 2 of 2
  1. Thread Author  Thread Author    #1  
    AC Question
    AC Question's Avatar
    Guest

    Default bonjour

    Svp je suis débutante en Android. Je veux faire une petite application qui permet d'afficher la liste des réseaux disponible. Concernant le code Java j'ai deux erreurs:
    * ligne 32 : main cannot be resolved or is not a field
    * ligne 33: mainText cannot be resolved or is not a field

    import java.util.List;
    import android.R;
    import android.app.Activity;
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.content.IntentFilter;
    import android.net.wifi.ScanResult;
    import android.net.wifi.WifiManager;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.widget.TextView;

    class WifiTester extends Activity {
    TextView mainText;
    WifiManager mainWifi;
    WifiReceiver receiverWifi;
    List wifiList;
    StringBuilder sb = new StringBuilder();

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main); //main cannot be resolved or is not a field
    mainText = (TextView) findViewById(R.id.mainText); //mainText cannot be resolved or is not a field
    mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    receiverWifi = new WifiReceiver();
    registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    mainWifi.startScan();
    mainText.setText("nStarting Scan...n");
    }

    public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 0, "Refresh");
    return super.onCreateOptionsMenu(menu);
    }

    public boolean onMenuItemSelected(int featureId, MenuItem item) {
    mainWifi.startScan();
    mainText.setText("Starting Scan");
    return super.onMenuItemSelected(featureId, item);
    }

    protected void onPause() {
    unregisterReceiver(receiverWifi);
    super.onPause();
    }

    protected void onResume() {
    registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    super.onResume();
    }

    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((wifiList.get(i)).toString());
    sb.append("n");
    }
    mainText.setText(sb);
    }
    }
    }

    et pour le code xml:

    ligne 2: //error parsing xml: unbond pefix


    //error parsing xml: unbond pefix
    package="com.Android.Wifiscanner"
    android:versionCode="1"
    android:versionName="1.0">

    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".WifiScannerActivity"
    android:label="@string/app_name">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />


    </application>
    Vous trouvez des commentaire devant l'erreur
    J'ai pas su les corriger. Merci beaucoup c'est très urgent
  2. #2  
    Golfdriver97's Avatar

    Posts
    25,682 Posts
    Global Posts
    26,125 Global Posts
    ROM
    Stock

    Default Re: bonjour

    Translation: Please, I am a beginner in Android. I want to make a small application that displays a list of available networks. Regarding the Java code I have two errors: * Line 32: main can not be resolved or is not a field
    * Line 33: mainText can not be resolved or is not a field


    import java.util.List;
    android.R import;
    android.app.Activity import;
    android.content.BroadcastReceiver import;
    android.content.Context import;
    android.content.Intent import;
    android.content.IntentFilter import;
    android.net.wifi.ScanResult import;
    android.net.wifi.WifiManager import;
    android.os.Bundle import;
    android.view.Menu import;
    android.view.MenuItem import;
    android.widget.TextView import;


    class extends Activity {WifiTester
    TextView mainText;
    WifiManager mainWifi;
    WifiReceiver receiverWifi;
    List wifiList;
    StringBuilder sb = new StringBuilder ();


    public void onCreate (Bundle savedInstanceState) {
    super.onCreate (savedInstanceState);
    setContentView (R.layout.main); // main can not be resolved or is not a field
    mainText = (TextView) findViewById (R.id.mainText); // mainText can not be resolved or is not a field
    mainWifi = (WifiManager) getSystemService (Context.WIFI_SERVICE);


    receiverWifi WifiReceiver = new ();
    registerReceiver (receiverWifi, new IntentFilter (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    mainWifi.startScan ();
    mainText.setText ("nStarting Scan ... n");
    }


    public boolean onCreateOptionsMenu (Menu menu) {
    menu.add (0, 0, 0, "Refresh");
    return super.onCreateOptionsMenu (menu);
    }


    public boolean onMenuItemSelected (int featureId, MenuItem item) {
    mainWifi.startScan ();
    mainText.setText ("Starting Scan");
    return super.onMenuItemSelected (featureId, item);
    }


    protected void onPause () {
    unregisterReceiver (receiverWifi);
    super.onPause ();
    }


    protected void onResume () {
    registerReceiver (receiverWifi, new IntentFilter (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    super.onResume ();
    }


    WifiReceiver class 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 ((wifiList.get (i)). toString ());
    sb.append ("n");
    }
    mainText.setText (sb);
    }
    }
    }


    and the xml code:


    Line 2: // error parsing xml: unbond pefix




    // error parsing xml: unbond pefix
    package = "com.Android.Wifiscanner"
    android: versionCode = "1"
    android: versionName = "1.0">


    <android app: icon = "@ drawable / icon" android: label = "@ string / app_name">
    <activity android: name = "WifiScannerActivity."
    android: label = "@ string / app_name">
    <intent-filter>
    <action android: name = "android.intent.action.MAIN" />
    <category android: name = "android.intent.category.LAUNCHER" />
    </ intent-filter>
    <uses-permission android: name = "android.permission.INTERNET" />




    </ application>
    You find the error to comment
    I have not been able to correct them. Thank you very much this is very urgent

    Hopefully this helps those who might know coding.

    What could not be changed, must be endured - New Spring, by Robert Jordan

    Community Guidelines and also here, Developer Rules, and Marketplace
    Mobile Nations Sister Forums: iMore/Connectedly/Windows Central/Crackberry
    Thanked by:

Similar Threads

  1. Bonjour!
    By cactuspwr in forum Introductions
    Replies: 9
    Last Post: 09-19-2013, 06:28 AM
  2. Bonjour; everybody .
    By bolochoko in forum Introductions
    Replies: 1
    Last Post: 05-26-2013, 08:05 PM
  3. Bonjour Ciao Hola Guten Tag!
    By 93Aero in forum Introductions
    Replies: 2
    Last Post: 05-01-2013, 10:22 AM
  4. Bonjour from France
    By Kidelia in forum Introductions
    Replies: 4
    Last Post: 04-25-2013, 09:51 AM
  5. Bonjour! Newbie near Toulouse, France
    By Simonflys in forum Introductions
    Replies: 1
    Last Post: 10-08-2012, 06:38 AM

Posting Permissions