QQ login for file storage and qq login for file storage

Source: Internet
Author: User

QQ login for file storage and qq login for file storage

Package com. jia. qqlogin; import java. util. map; import com. jia. qqlogin. utils. utils; import android. app. activity; import android. OS. bundle; import android. text. textUtils; import android. util. log; import android. view. view; import android. view. view. onClickListener; import android. widget. button; import android. widget. checkBox; import android. widget. editText; import android. widget. toast; public class MainActivity ext Ends Activity implements OnClickListener {private static final String TAG = "jia"; private EditText etNumber; private EditText etPassword; private CheckBox cbRemerberPWD; @ Overrideprotected void onCreate (Bundle savedInstanceState. onCreate (savedInstanceState); setContentView (R. layout. activity_main); etNumber = (EditText) findViewById (R. id. et_number); etPassword = (EditText) findViewById (R. id. et_pa Ssword); cbRemerberPWD = (CheckBox) findViewById (R. id. cb_remerber_pwd); Button btnLogin = (Button) findViewById (R. id. btn_login); btnLogin. setOnClickListener (this); // Echo Data Map <String, String> userInfoMap = Utils. getUserInfo (); if (userInfoMap! = Null) {etNumber. setText (userInfoMap. get ("number"); etPassword. setText (userInfoMap. get ("password") ;}@overridepublic void onClick (View v) {// perform the logon operation // 1. retrieve the number and password String number = etNumber. getText (). toString (); String password = etPassword. getText (). toString (); if (TextUtils. isEmpty (number) | TextUtils. isEmpty (password) {// The Toast is displayed. makeText (this, "Enter it correctly", Toast. LENGTH_SHORT ). show (); return;} // 2. determine whether the password is selected. if it is selected, save it as if (cbRemerberPWD. isChecked () {// you need to remember the password Log. I (TAG, "Remember password:" + number + "," + password); boolean isSuccess = Utils. saveUserInfo (number, password); if (isSuccess) {Toast. makeText (this, "saved successfully", 0 ). show ();} else {Toast. makeText (this, "failed to save", 0 ). show () ;}// 3. toast is successfully logged on. makeText (this, "Logon successful", 0 ). show ();}}

Package com. jia. qqlogin. utils; import java. io. bufferedReader; import java. io. fileInputStream; import java. io. fileOutputStream; import java. io. inputStreamReader; import java. util. hashMap; import java. util. map; import android. text. textUtils; public class Utils {/*** Save User Information ** @ param number * @ param password * @ return true success */public static boolean saveUserInfo (String number, String password) {String path = "/Data/com. jia. qqlogin/QQpassword.txt "; try {FileOutputStream fos = new FileOutputStream (path); // Account # password String data = number +" ## "+ password; fos. write (data. getBytes (); fos. flush (); fos. close (); return true;} catch (Exception e) {// TODO Auto-generated catch blocke. printStackTrace ();} return false;}/*****/public static Map <String, String> getUserInfo () {String path = "/data/com. jia. qqlog In/QQpassword.txt "; // java basic try {FileInputStream FCM = new FileInputStream (path); // The Stream object BufferedReader reader = new BufferedReader (new InputStreamReader (FS )); // Account # password String text = reader. readLine (); if (! TextUtils. isEmpty (text) {String [] split = text. split ("#"); Map <String, String> userInfoMap = new HashMap <String, String> (); userInfoMap. put ("number", split [0]); userInfoMap. put ("password", split [1]); return userInfoMap;} catch (Exception e) {// TODO Auto-generated catch blocke. printStackTrace ();} return null ;}}

<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: orientation = "vertical"> <EditText android: id = "@ + id/et_number" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: hint = "Enter QQ number"/> <EditText android: id = "@ + id/et_password" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: hint = "enter the password" android: inputType = "textPassword"/> <CheckBox android: id = "@ + id/cb_remerber_pwd" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: checked = "true" android: hint = "Remember password"/> <Button android: id = "@ + id/btn_login" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = "login"/> </LinearLayout>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.