Reputation: 4850
I have my simple PreferenceActivity class and its onCreate passes my R.xml.preferences
screen to ((PreferenceActivity)super).addPreferencesFromResource
. Finally, in my AndroidManifest.xml my activity as follows:
<activity android:name="com.criticalrf.jwalkietalkie.PreferenceServerActivity" >
<intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
On the device, the menu button will trigger a menu with only the word "Settings." Clicking on Settings makes the Settings button go away but does not show anything. Do I need to add something in my MainActivity? I followed this guide, I'm not sure what I missed.
Upvotes: 1
Views: 107
Reputation: 1301
If you want to open this preference activity from your main activity you should call somewhere in your MainActivity:
startActivity(new Intent(this, PreferenceServerActivity.class));
and preference activity will show.
Typical implementation would be doing it with options menu. Like:
private static final int SettingsId = 1;
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
menu.add(0, SettingsId, 0, "Settings");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case SettingsId:
startActivity(new Intent(this, PreferenceServerActivity.class));
return true;
default:
return false;
}
}
Intent filter in your manifest from tutorial just says, that this activity can be opened from system settings when user browse data usage of your app.
Upvotes: 1