[Android] mobile guard saves security numbers and android guard

Source: Internet
Author: User

[Android] mobile guard saves security numbers and android guard

 

Call the setOnItemClickListener () method of the ListView object and set the Click Event of the entry. Parameter: OnItemClickListener object

Use the anonymous internal class implementation, override the onClick () method, and pass in parameters: ListView, current View, position, id

Upload the current phone number back Based on the index location

Call the get () method of the List object to obtain the Map. Call the get (key) method to obtain this call.

Call the setResult () method to return the de-data, parameters: response code, Intent object

Get Intent object, new

Call the putExtra (key, val) of the Intent object and put the phone in

Call the finish () method to close the current page

 

StartActivityForResult () is used to enable this activity ()

Override the onActivityResult () method and pass in the Intent object

Judge whether Intent object is null

Call the getStringExtra () method of the Intent object to obtain the phone number.

Put the phone number on Edittext and save it to SP when you click Next.

Activity

 

Package com. qingguow. mobilesafe; import android. content. intent; import android. content. sharedPreferences; import android. content. sharedPreferences. editor; import android. OS. bundle; import android. text. textUtils; import android. view. view; import android. widget. editText; import android. widget. toast; public class SecGuide3Activity extends BaseSecGuideActivity {private EditText et_sec_phone; private SharedPref Erences sp; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_lost_find3); et_sec_phone = (EditText) findViewById (R. id. et_sec_phone); sp = getSharedPreferences ("config", MODE_PRIVATE); String phone = sp. getString ("secphone", ""); et_sec_phone.setText (phone);} public void nextStep (View v) {showNext ();} public void PreStep (View v) {showPre () ;}@ Override public void showPre () {Intent intent = new Intent (this, SecGuide2Activity. class); startActivity (intent); finish () ;}@ Override public void showNext () {String phone = et_sec_phone.getText (). toString (). trim (); if (TextUtils. isEmpty (phone) {Toast. makeText (this, "Enter the Security number", 1 ). show (); return;} Editor editor = sp. edit (); editor. putString ("secphone", phone ); Editor. commit (); Intent intent = new Intent (this, SecGuide4Activity. class); startActivity (intent); finish () ;}/ *** select contact */public void selectContacts (View v) {Intent intent = new Intent (this, SelectContactsActivity. class); startActivityForResult (intent, 0) ;}@ Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {// TODO Auto-generated method stub super. onAct IvityResult (requestCode, resultCode, data); if (data! = Null) {String phone = data. getStringExtra ("phone "). replace ("-",""). replace ("", ""); et_sec_phone.setText (phone );}}}

 

SelectContactsActivity

Package com. qingguow. mobilesafe; import java. util. list; import java. util. map; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. view; import android. widget. adapterView; import android. widget. adapterView. onItemClickListener; import android. widget. listView; import android. widget. simpleAdapter; import com. qingguow. mobilesafe. utils. phoneContactsUtil;/*** select Contact * @ author taoshihan **/public class SelectContactsActivity extends Activity {private ListView lv_select_contacts; private List <Map <String, String> contacts; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_select_contacts); lv_select_contacts = (ListView) findViewById (R. id. lv_select_contacts); contacts = PhoneCont ActsUtil. getContacts (this); lv_select_contacts.setAdapter (new SimpleAdapter (this, contacts, R. layout. select_contacts_item, new String [] {"name", "phone"}, new int [] {R. id. TV _contact_name, R. id. TV _contact_phone}); lv_select_contacts.setOnItemClickListener (new OnItemClickListener () {@ Override public void onItemClick (AdapterView <?> Arg0, View arg1, int position, long arg3) {String phone = contacts. get (position ). get ("phone"); Intent data = new Intent (); data. putExtra ("phone", phone); setResult (0, data); finish ();}});}}

 

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.