android 判断手机是否插入SIM卡

代码片段如下:

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
		String simSer = tm.getSimSerialNumber();
		if(simSer == null || simSer.equals("")) {
			//Toast.makeText(this, "插入SIM卡才能开启此应用", Toast.LENGTH_LONG).show();
			Builder builder = new AlertDialog.Builder(this);
			builder.setIcon(R.drawable.datasync);
			builder.setTitle("插入SIM卡才能开启此应用");
			builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which) {
					System.exit(0);
				}
				
			});
			builder.show();
			
		}


你可能感兴趣的:(android,android的组件)