An analysis of Android phone defender turn off automatic Updates _android

Source: Internet
Author: User

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!

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.