代码之家  ›  专栏  ›  技术社区  ›  Moin Khan

如何在android中使用两个web服务?

  •  0
  • Moin Khan  · 技术社区  · 5 年前

    public class AppConfig {
    
        private static String TAG = SessionManager.class.getSimpleName();
    
        // Shared Preferences
        SharedPreferences pref;
    
        SharedPreferences.Editor editor;
        Context _context;
    
        // Shared pref mode
        int PRIVATE_MODE = 0;
    
        // Shared preferences file name
        private static final String PREF_NAME = "Login";
    
        AppConfig appConfig = new AppConfig(_context.getApplicationContext());
    
        public static String BASE_URL = appConfig.apiDecider();
    
        public static String login = BASE_URL + "Login";
    
        public AppConfig(Context context) {
            this._context = context;
            pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
            editor = pref.edit();
        }
    
        public String apiDecider(){
    
            String lc = pref.getString("locationSession", null);
    
            //String lc = locationPref.getString("locationSession", null);
    
            String url = "";
    
            if (lc.equals("U") && lc != null) {
    
                url = "";
    
            } else if (lc.equals("S") && lc != null) {
    
                url = "";
            }
    
            return url;
        }
    }
    
    0 回复  |  直到 5 年前