1. 程式人生 > >android 仿 淘寶淘口令

android 仿 淘寶淘口令

複製*wangbin1*口令   開啟APP 在主activity  onResume中執行程式碼塊
public void GangUpInvite(final Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
    //無資料時直接返回
    if (!clipboard.hasPrimaryClip()) {
        return;
    }
    //如果是文字資訊
    if (clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
        ClipData cdText = clipboard.getPrimaryClip();
        ClipData.Item item = cdText.getItemAt(0);
        //此處是TEXT文字資訊
        if (item.getText() != null) {
            String str = item.getText().toString();
            String key = "*";
            final int first = str.indexOf(key);
            if (first >= 0) {
                String new1 = str.substring(first + 1);
                int tow = new1.indexOf(key);
                if (tow >= 0) {
                    String new2 = new1.substring(0, tow);
                    System.out.print(new2);
                    if (new2.length() == 8) {

                        //new2即為口令字串

                    }
                }

            }
        }
    }
}
取到key配合後端 獲取該口令相關資訊