當前位置:首頁 » 安卓系統 » androidifid

androidifid

發布時間: 2022-04-26 18:09:07

⑴ 安卓開發 創建按鈕if語句

對按鈕事件進行監聽

public void onClick方法裡面寫按鈕處理事件。

希望能幫到你

⑵ 如何修改android模擬器上的IMEI,IMSI,SIM card serial number

手機使用IMEI和IMSI登錄到GSM網路的,由GSM網路側負責將IMSI和映射成手機號(MSISDN),以及執行相反方向的映射。

(一)、SIM card 號的修改:
SIM card號就是印製在SIM上的一串數字。
讀SIM card號的AT命令為:AT+CRSM=176,12258,0,0,10
因此在andorid模擬其源碼中找到該AT命令——在sim_card.c中:
const char*
asimcard_io( ASimCard sim, const char* cmd )
{
int nn;
#if ENABLE_DYNAMIC_RECORDS
int command, id, p1, p2, p3;
#endif
static const struct { const char* cmd; const char* answer; } answers[] =
{
{ "+CRSM=192,28436,0,0,15", "+CRSM: 144,0," },
{ "+CRSM=176,28436,0,0,20", "+CRSM: 144,0," },

{ "+CRSM=192,28433,0,0,15", "+CRSM: 144,0," },
{ "+CRSM=176,28433,0,0,1", "+CRSM: 144,0,55" },

{ "+CRSM=192,12258,0,0,15", "+CRSM: 144,0," },
{ "+CRSM=176,12258,0,0,10", "+CRSM: 144,0,98101430121181157002" },

...

...

因此用UE二進制方式打開emulator-arm.exe 或 emulator-x86.exe,並搜索字元串「98101430121181157002」,然後將其修改成需要的SIM card號。
比如:
00209a00h: 31 30 00 00 2B 43 52 53 4D 3A 20 31 34 34 2C 30 ; 10..+CRSM: 144,0
00209a10h: 2C 39 38 31 30 31 34 33 30 31 32 31 31 38 31 31 ; ,981014301211811
00209a20h: 35 37 30 30 32 00 2B 43 52 53 4D 3D 31 39 32 2C ; 57002.+CRSM=192,

(二)、IMEI、IMSI號的修改:

Java代碼中獲取手機的IMEI號與ISMI號途徑為:

TelephonyManager manager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei = manager.getDeviceId();
String imsi = manager.getSubscriberId();

在android的源碼樹中找到類TelephonyManager的實現:
成員函數getDeviceId:
/**
* Returns the unique device ID, for example, the IMEI for GSM and the MEID
* or ESN for CDMA phones. Return null if device ID is not available.
*
* <p>Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
public String getDeviceId() {
try {
return getSubscriberInfo().getDeviceId();
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
return null;
}
}

成員函數getSubscriberId:
/**
* Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
* Return null if it is unavailable.
* <p>
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
public String getSubscriberId() {
try {
return getSubscriberInfo().getSubscriberId();
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
// This could happen before phone restarts e to crashing
return null;
}
}

上面兩個成員函數最終調用共同的一個私有成員函數getSubscriberInfo():
private IPhoneSubInfo getSubscriberInfo() {
// get it each time because that process crashes a lot
return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo"));
}

而上面私有函數getSubscriberInfo獲取的手機IMSI和IMEI號被硬編碼在文件android_modem.c中:
/* the Android GSM stack checks that the operator's name has changed
* when roaming is on. If not, it will not update the Roaming status icon
*
* this means that we need to emulate two distinct operators:
* - the first one for the 'home' registration state, must also correspond
* to the emulated user's IMEI
*
* - the second one for the 'roaming' registration state, must have a
* different name and MCC/MNC
*/

#define OPERATOR_HOME_INDEX 0
#define OPERATOR_HOME_MCC 310
#define OPERATOR_HOME_MNC 260
#define OPERATOR_HOME_NAME "Android"
#define OPERATOR_HOME_MCCMNC STRINGIFY(OPERATOR_HOME_MCC) \
STRINGIFY(OPERATOR_HOME_MNC)

#define OPERATOR_ROAMING_INDEX 1
#define OPERATOR_ROAMING_MCC 310
#define OPERATOR_ROAMING_MNC 295
#define OPERATOR_ROAMING_NAME "TelKila"
#define OPERATOR_ROAMING_MCCMNC STRINGIFY(OPERATOR_ROAMING_MCC) \
STRINGIFY(OPERATOR_ROAMING_MNC)
/* a function used to deal with a non-trivial request */
typedef const char* (*ResponseHandler)(const char* cmd, AModem modem);

static const struct {
const char* cmd; /* command coming from libreference-ril.so, if first
character is '!', then the rest is a prefix only */

const char* answer; /* default answer, NULL if needs specific handling or
if OK is good enough */

ResponseHandler handler; /* specific handler, ignored if 'answer' is not NULL,
NULL if OK is good enough */
} sDefaultResponses[] =
{
/* see onRadioPowerOn() */
{ "%CPHS=1", NULL, NULL },
{ "%CTZV=1", NULL, NULL },

...

{ "!+VTS=", NULL, handleSetDialTone },
{ "+CIMI", OPERATOR_HOME_MCCMNC "000000000", NULL }, /* request internation subscriber identification number */
{ "+CGSN", "000000000000000", NULL }, /* request model version */
{ "+CUSD=2",NULL, NULL }, /* Cancel USSD */

...

/* end of list */
{NULL, NULL, NULL}

};

因此用UE二進制方式打開emulator-arm.exe 或 emulator-x86.exe,並搜索字元串"+CGSN"修改為需要的IMEI號;搜索"+CIMI"修改為需要的IMSI號。需要注意的是 IMSI 號的頭六個數字"310260"不能修改,否則模擬器無法與網路連接。
例如:
001fc700h: 33 00 41 00 48 00 21 2B 56 54 53 3D 00 2B 43 49 ; 3.A.H.!+VTS=.+CI
001fc710h: 4D 49 00 33 31 30 32 36 30 30 30 30 30 30 30 30 ; MI.3102600000000
001fc720h: 30 30 00 2B 43 47 53 4E 00 30 30 30 30 30 30 30 ; 00.+CGSN.0000000
001fc730h: 30 30 30 30 30 30 30 30 00 2B 43 55 53 44 3D 32 ; 00000000.+CUSD=2

⑶ android動態創建的Textview怎麼獲取或者給他設置一個ID

ID本身是個int類型的,就算設置也只能給一個隨機不重復的int數字,但是如果想要通過字元串去實現,用個HashMap把鍵值對存下來

final static HashMap<String, Integer> listView = new HashMap<String, Integer>();

賦值ID linearLayout.setId(唯一id);

鍵值對 listView.put(字元串id, 前邊定義的唯一int ID);

獲取:

public static Integer getViewIdById(String id){
if (listView.containsKey(id))
return listView.get(id);
else
return -1;
}

⑷ android 怎麼判斷當前id

下面是通過linux命令來獲取進程ID的
Process psProcess = Runtime.getRuntime().exec("sh");
DataOutputStream out = new DataOutputStream( psProcess.getOutputStream() );
InputStream is = psProcess.getInputStream();
out.writeBytes( "ps | grep 'vpnloader' | cut -c 10-14\n" );
out.writeBytes( "ps\n" );
out.flush();
try {
psProcess.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();}

if(is.read() != 0)
{
byte firstByte = (byte)is.read();
int available = is.available();
byte[] characters = new byte[available + 1];
characters[0] = firstByte;
is.read( characters, 1, available );
String re = new String( characters );

⑸ Android L 判斷是否有NavigationBar的方式

Android L中,如何得知是否有虛擬按鍵呢。查看了下PhoneWindowManager中的代碼,這會在這整理處如下方法:
獲取是否存在NavigationBar:
private static boolean checkDeviceHasNavigationBar(Context context) {
boolean hasNavigationBar = false;
Resources rs = context.getResources();
int id = rs.getIdentifier("config_showNavigationBar", "bool", "android");
if (id > 0) {
hasNavigationBar = rs.getBoolean(id);
}
try {
Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
Method m = systemPropertiesClass.getMethod("get", String.class);
String navBarOverride = (String) m.invoke(systemPropertiesClass, "qemu.hw.mainkeys");
if ("1".equals(navBarOverride)) {
hasNavigationBar = false;
} else if ("0".equals(navBarOverride)) {
hasNavigationBar = true;
}
} catch (Exception e) {
Log.w(TAG, e);
}

return hasNavigationBar;

}
獲取NavigationBar的高度:
private static int getNavigationBarHeight(Context context) {
int navigationBarHeight = 0;
Resources rs = context.getResources();
int id = rs.getIdentifier("navigation_bar_height", "dimen", "android");
if (id > 0 && checkDeviceHasNavigationBar(context)) {
navigationBarHeight = rs.getDimensionPixelSize(id);
}
return navigationBarHeight;
}

⑹ android studio if語句問題,要求布爾型的,可我按鈕是int型,按老師課上講的打出來的,求解

==是等於,=是賦值

⑺ 如何獲取 android device id

因為在工作中要統計一些用戶的數據,以及愛好等等..所以就要統計不同用戶!所以剛開始用device id 如下:/**
Java代碼
* 獲取機器唯一標識
* @param _context
* @return
*/
public String getLocaldeviceId(Context _context){
TelephonyManager tm = (TelephonyManager) _context
.getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
if (deviceId == null
|| deviceId.trim().length() == 0) {
deviceId = String.valueOf(System
.currentTimeMillis());
}
return deviceId ;
}

我理解為類似手機的出廠標號,但是有很多的是無法獲取到device id的!所以,就要獲取mac地址

mac地址很好理解,就是用戶上網的上網許可證,這個買手機的時候,你翻開電池就知道裡面有一個標簽!

下面是獲取mac地址的代碼

Java代碼
/**
* 獲取mac地址
* @param context
* @return
*/
public String getLocalMacAddress(Context context) {
WifiManager wifi = (WifiManager) context.getSystemService(
Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
return info.getMacAddress();
}

熱點內容
太原php培訓班 發布:2025-05-15 08:41:38 瀏覽:937
豌豆伺服器地址 發布:2025-05-15 08:34:56 瀏覽:712
linux下php編譯安裝 發布:2025-05-15 08:30:37 瀏覽:592
c語言八進制十六進制 發布:2025-05-15 08:22:17 瀏覽:282
華為安卓如何更新鴻蒙 發布:2025-05-15 08:18:52 瀏覽:373
工商密碼器是什麼 發布:2025-05-15 08:18:50 瀏覽:751
c語言自考 發布:2025-05-15 07:52:42 瀏覽:501
壓縮的玉 發布:2025-05-15 07:51:22 瀏覽:790
android的控制項 發布:2025-05-15 07:50:36 瀏覽:553
南崗法院伺服器ip地址 發布:2025-05-15 07:46:02 瀏覽:288