Java tutorial
// // _/_/_/ _/ _/_/_/_/_/ // _/ _/_/ _/_/ _/ _/ _/ _/_/ _/_/ // _/ _/_/ _/_/_/_/ _/_/_/_/ _/_/ _/ _/ _/ _/ _/ // _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ // _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/_/_/ _/_/ _/_/ // // // Copyright (c) 2015-2016, Geek Zoo Studio // http://www.geek-zoo.com // // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // package com.firesoft.member; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.telephony.TelephonyManager; import com.BeeFramework.BeeFrameworkApp; import com.external.anyversion.AnyVersion; import com.external.anyversion.Version; import com.external.anyversion.VersionParser; import com.firesoft.member.Utils.LocationManager; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; public class Member extends BeeFrameworkApp { public static DisplayImageOptions options; // DisplayImageOptions public static DisplayImageOptions options_head; // DisplayImageOptions public static DisplayImageOptions options_home; @Override public void onCreate() { super.onCreate(); initUpdate(); String device_id = Member.getDeviceId(getApplicationContext()); SharedPreferences shared; SharedPreferences.Editor editor; shared = this.getSharedPreferences(MemberAppConst.USERINFO, 0); editor = shared.edit(); editor.putString(Config.DEVICE_UUID, device_id); editor.commit(); options = new DisplayImageOptions.Builder().showStubImage(R.drawable.default_image) // .showImageForEmptyUri(R.drawable.default_image) // Uri .showImageOnFail(R.drawable.default_image) // ?? .cacheInMemory(true) // ? .cacheOnDisc(true) // ?SD? // .displayer(new RoundedBitmapDisplayer(20)) // ? .bitmapConfig(Bitmap.Config.RGB_565).build(); options_head = new DisplayImageOptions.Builder().showStubImage(R.drawable.e8_profile_no_avatar) // .showImageForEmptyUri(R.drawable.e8_profile_no_avatar) // Uri .showImageOnFail(R.drawable.e8_profile_no_avatar) // ?? .cacheInMemory(true) // ? .cacheOnDisc(true) // ?SD? .displayer(new RoundedBitmapDisplayer(30)) // ? .build(); options_home = new DisplayImageOptions.Builder().showStubImage(R.drawable.home_icon_bg) // .showImageForEmptyUri(R.drawable.home_icon_bg) // Uri .showImageOnFail(R.drawable.home_icon_bg) // ?? .cacheInMemory(true) // ? .cacheOnDisc(true) // ?SD? .build(); LocationManager locationManager = new LocationManager(this); locationManager.refreshLocation(); } private void initUpdate() { AnyVersion.init(this, new VersionParser() { @Override public Version onParse(String response) { final JSONTokener tokener = new JSONTokener(response); try { JSONObject json = (JSONObject) tokener.nextValue(); return new Version(json.getString("name"), json.getString("note"), json.getString("url"), json.getInt("code")); } catch (JSONException e) { e.printStackTrace(); } return null; } }); } public int getCacheUserId() { SharedPreferences shared; SharedPreferences.Editor editor; shared = this.getSharedPreferences(MemberAppConst.USERINFO, 0); editor = shared.edit(); int userId = shared.getInt("uid", 0); return userId; } public static String getDeviceId(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE); String deviceId = tm.getDeviceId(); return deviceId; } }