UpcApp.java 1.14 KB
package com.upc.pbe.upcnews;

import android.app.Application;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.preference.PreferenceManager;
import android.util.Log;


public class UpcApp extends Application implements OnSharedPreferenceChangeListener {

	final static String TAG = "Application";
	SharedPreferences prefs;
	String defaultUrl = "10.0.2.100";
	String url = null;
	String desc;
	
	public String getUrl() {
		url = "http://" + prefs.getString("s", defaultUrl);
		return url;
	}


	public void onCreate() {
		super.onCreate();
		
		//Prefs
		prefs = PreferenceManager.getDefaultSharedPreferences(this); 
		prefs.registerOnSharedPreferenceChangeListener(this);
		this.getUrl();
		Log.d(TAG, "onCreated");
	}
	
	
	
	public SharedPreferences getPrefs() {
		return prefs;
	}


	public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
		
		Log.d(TAG, "onSharedPreferenceChanged for key: " + key);
		
	}
	
	public void setDesc(String s){
		desc = s;
		
	}
	
	public String getDesc(){
		return desc;
	}

}