Android Open Source - Gents Echo Server Preference Activity






From Project

Back to project page Gents.

License

The source code is released under:

MIT License

If you think the Android project Gents listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.gsfraley.gents.service.servers.echoserver;
//w w  w  .  java  2  s  . c o m
import org.gsfraley.gents.R;

import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.view.Menu;

public class EchoServerPreferenceActivity extends Activity {
  public final static String SERVER_PREF_NAME = "server_pref_name";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    String serverPrefName = getIntent().getExtras().getString(SERVER_PREF_NAME, EchoServer.NAME);
    
    PreferenceFragment prefFragment = new HelloServerPreferenceFragment();
    Bundle args = new Bundle();
    args.putString(SERVER_PREF_NAME, serverPrefName);
    prefFragment.setArguments(args);
    
    getFragmentManager().beginTransaction()
      .replace(android.R.id.content, prefFragment)
      .commit();
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.echo_server_preference, menu);
    return true;
  }

  
  public static class HelloServerPreferenceFragment extends PreferenceFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Bundle args = getArguments();
      
      PreferenceManager pm = getPreferenceManager();
      pm.setSharedPreferencesName(args.getString(SERVER_PREF_NAME));
      pm.setSharedPreferencesMode(MODE_PRIVATE);
      
      addPreferencesFromResource(R.xml.servers_echoserver_preference);
    }
  }
}




Java Source Code List

fi.iki.elonen.NanoHTTPD.java
org.gsfraley.gents.app.adapters.RunningServerAdapter.java
org.gsfraley.gents.app.adapters.ServerTypeAdapter.java
org.gsfraley.gents.app.fragments.RunningServerFragment.java
org.gsfraley.gents.app.fragments.ServerTypeFragment.java
org.gsfraley.gents.app.main.MainActivityListener.java
org.gsfraley.gents.app.main.MainActivity.java
org.gsfraley.gents.service.ManagerListener.java
org.gsfraley.gents.service.ServerBoss.java
org.gsfraley.gents.service.ServerGhost.java
org.gsfraley.gents.service.ServerManager.java
org.gsfraley.gents.service.servers.echoserver.EchoServerPreferenceActivity.java
org.gsfraley.gents.service.servers.echoserver.EchoServer.java
org.gsfraley.gents.service.servers.helloserver.HelloServerPreferenceActivity.java
org.gsfraley.gents.service.servers.helloserver.HelloServer.java
org.gsfraley.gents.service.servers.nullserver.NullServer.java
org.gsfraley.gents.service.servers.yesserver.YesServerPreferenceActivity.java
org.gsfraley.gents.service.servers.yesserver.YesServer.java