I'm trying to open open the wifi setting programmatically in an andoird app. It works on most devices, but on an android tablet it crashes and gives me this error:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.settings/com.android.settings.wifi.WifiSettings}; have you declared this activity in your AndroidManifest.xml?
Here is my code in the main activity:
Button wifisettings = (Button) findViewById(R.id.WiFiSettings);
wifisettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.wifi.WifiSettings");
intent.setComponent(cn);
intent.setFlags(intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});