一些东西

计算IMEI


private String changeIMEI() {// calculator IMEI
		int r1 = 1000000 + new Random().nextInt(10000000);
		int r2 = 1000000 + new Random().nextInt(10000000);
		String input = r1 + "" + r2;
		char[] ch = input.toCharArray();
		int a = 0, b = 0;
		for (int i = 0; i < ch.length; i++) {
			int tt = Integer.parseInt(ch[i] + "");
			if (i % 2 == 0) {
				a = a + tt;
			} else {
				int temp = tt * 2;
				b = b + temp / 10 + temp % 10;
			}
		}
		int last = (a + b) % 10;
		if (last == 0) {
			last = 0;
		} else {
			last = 10 - last;
		}
		return input + last;
	}


清除 Userdata 

class ClearUserDataObserver extends IPackageDataObserver.Stub {
		public void onRemoveCompleted(final String packageName,
				final boolean succeeded) {
			Log.v("tag", packageName + "----> " + succeeded);
		}
	}

	private void ClearUserData() {
		if (pakagMap == null) {
			initData();
		}
		Set<String> pkgSet = (Set<String>) pakagMap.keySet();
		for (String pname : pkgSet) {
			ClearUserDataObserver mClearDataObserver = null;
			if (mClearDataObserver == null) {
				mClearDataObserver = new ClearUserDataObserver();
			}
			ActivityManager am = (ActivityManager) MainActivity.this
					.getSystemService(Context.ACTIVITY_SERVICE);
			boolean res = am
					.clearApplicationUserData(pname, mClearDataObserver);
		}
		WriteIMEI();
	}


你可能感兴趣的:(一些东西)