startActivity for external app needs <activity> declared?
I want to be able to open Android's stock Wifi Settings screen from my app, got this code:
Intent settings = new Intent(Settings.ACTION_WIFI_SETTINGS);
settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(settings);
I get "Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45a3df40"
If I'm correct I need to declare the activity in my manifest.. but HOW? I've tried this:
<activity android:name="android.settings.WIFI_SETTINGS" />
Or am I doing something else wrong??
开发者_如何学GoUPDATE: I was trying to access the Wifi Settings Activity from an PreferenceActivity's onOptionsItemSelected method. This DOES NOT WORK for either startActivity, startService OR sendBroadcast.
The answer below DOES work in pretty much every other scenario.. :)
You only have to declare your activities in your manifest. Not the one that belong to external programs.
And remove the flags in your intent, I can't see the point for them.
startActivity( new Intent(android.provider.settings.Settings.ACTION_WIFI_SETTINGS) );
精彩评论