Recommended reading:
A brief analysis of Android phone defender custom control properties
Four ways to save data, network, broadcast provider, sharedpreferences, database
Gets the Sharedpreferences object through the Getsharedpreferences () method, Parameters: name, pattern
such as Config,mode_private
Call the Sharedpreferences object's edit () method to get the editor object
Invokes the Putboolean () method of the Editor object, putting the Boolean data, Parameters: key-value pairs, "Update" false
Invokes the commit () method of the Editor object, submitting the data
View/data/data/Package name/shared_perfs/config.xml This generated XML file
Use the command line ADB shell CD to the above directory to view files using the Cat command
Call the Sharedpreferences object's Getboolean () method to get the saved data, parameters: keys, default values
Make a decision, set the status to Ture, set the text content
Set Check Download section
The state of being saved automatically updated, the state of judgment
If Automatic Updates are invoked, code that detects Automatic Updates is called
If not automatically updated, delay two seconds, automatically jump to the home page
Call the Handler object's Postdelayed () method, Parameter: Runable object, number of milliseconds deferred
Use anonymous inner class to inherit Runable object, rewrite the Run () method, and jump to the home page
TextView part of the upgrade progress, default hidden, android:visibility= "Gone" Gone is hidden and vacated
In the callback function in the download process, this moment is displayed
Call the TextView object's setvisibility (view.visible)
Settingactivity:
Package Com.qingguow.mobilesafe;
Import android.app.Activity;
Import android.content.SharedPreferences;
Import Android.content.SharedPreferences.Editor;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Com.qingguow.mobilesafe.ui.SettingItemView;
public class Settingactivity extends activity {private Settingitemview siv_item; private sharedpreferences sp; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (
r.layout.activity_setting);
Siv_item= (Settingitemview) Findviewbyid (R.id.siv_item);
Sp=getsharedpreferences ("config", mode_private);
Sets the state Boolean Update=sp.getboolean ("Update", false) based on the saved data; if (update) {siv_item.setchecked (true); Siv_item.setdesc ("Automatic Update is already on"); else{siv_item.setchecked (false); Siv_item.setdesc ("Automatic update is turned off")//automatically updated click event Siv_item.setonclicklistener (new Onclicklistener () {@Override public void OnClick (View arg0) {Editor editor=sp.edit (); if (siv_item.iSchecked ()) {//Set uncheck Siv_item.setchecked (false), SIV_ITEM.SETDESC ("Automatic update is turned off"), Editor.putboolean ("Update", false);}
else{//Set Check siv_item.setchecked (true); Siv_item.setdesc ("Automatic Update is turned on") Editor.putboolean ("Update", True);}
Editor.commit ();
}
}); }
}
The above content is small series to introduce the Android mobile phone defender to turn off automatic Updates related knowledge, I hope to help you!