Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I used your code only without changing anything except added permissions in manifest file. Its working for me Check the code</p> <pre><code>public class MainActivity extends Activity { WifiManager Wifi; BroadcastReceiver receiver; List&lt;ScanResult&gt; results; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //GUI bt1=(Button)findViewById(R.id.btn1); t1=(TextView)findViewById(R.id.txt1); // to enable wifi service Wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); bt1.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { WifiInfo info = Wifi.getConnectionInfo(); if (info.getBSSID()==null) { t1.setText("You are currently not connected to any wireless network.\n"); } else { t1.append("Current Status:\n"); t1.append("Network Name :"+info.getSSID().toString()+"\n"); t1.append("RSSI :"+info.getRssi()+"\n"); } } }); Wifi.startScan(); // Register Broadcast Receiver if (receiver == null) receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { results =Wifi.getScanResults(); // Intent I1 =new Intent(); } }; registerReceiver(receiver, new IntentFilter( WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); } /*@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_wizer, menu); return true; }*/ public void onStop() { unregisterReceiver(receiver); } } </code></pre> <p>Manifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.textoverlay" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.textoverlay.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload