Created
September 20, 2014 05:44
-
-
Save moltak/a6b5fc0bfbc0b465c11d to your computer and use it in GitHub Desktop.
안드로이드 디바이스 정보 가져오기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.day1song.app.tools; | |
import android.content.Context; | |
import android.content.pm.PackageInfo; | |
import android.content.pm.PackageManager; | |
import android.net.wifi.WifiInfo; | |
import android.net.wifi.WifiManager; | |
import android.os.Build; | |
import android.provider.Settings; | |
import android.telephony.PhoneStateListener; | |
import android.telephony.ServiceState; | |
import android.telephony.SignalStrength; | |
import android.telephony.TelephonyManager; | |
import java.io.UnsupportedEncodingException; | |
import java.net.URLEncoder; | |
/** | |
* Created by moltak on 3/19/14. | |
* 핸드폰 정보를 간단히 가져오기 위한 Helper 클래스. | |
*/ | |
public class BringMobileInfo { | |
public static String getAppVersion(Context context) throws PackageManager.NameNotFoundException, UnsupportedEncodingException { | |
PackageInfo i = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); | |
return URLEncoder.encode(i.versionName, "utf-8"); | |
} | |
public static String getDeviceName() throws UnsupportedEncodingException { | |
return URLEncoder.encode(android.os.Build.MODEL, "utf-8"); | |
} | |
public static String getDeviceId(Context context) throws UnsupportedEncodingException { | |
String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); | |
return URLEncoder.encode(android_id, "utf-8"); | |
} | |
public static String getDeviceNameNotEncoded() { | |
return android.os.Build.MODEL; | |
} | |
public static String getOsVersion() { | |
return Build.VERSION.RELEASE; | |
} | |
public static int getOsSdkInt() { | |
return Build.VERSION.SDK_INT; | |
} | |
public static String getWifiInfo(Context context) { | |
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | |
WifiInfo wifiInfo = wifiManager.getConnectionInfo(); | |
String ssid = wifiInfo.getSSID(); | |
int rssi = wifiInfo.getRssi(); | |
String supplicantState = wifiInfo.getSupplicantState().name(); | |
String msg = String.format("SSID: %s, rssi: %d, ApState: %s", ssid, rssi, supplicantState); | |
return msg; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment