Learn mobile security guard project source code record

Source: Internet
Author: User

 

 


 

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

 

 

 

 

AlertDialog. builder builder = Builder (builder. setTitle ("upgrade prompt" builder. setMessage ("" builder. setPositiveButton ("Upgrade", onClick (DialogInterface dialog, builder. setNegativeButton ("cancel", onClick (DialogInterface dialog ,}

 

 

 

String serverurl = getResources (). getString (R. string. serverurl): Obtain the URL address for accessing the server configuration information (that is, the info. xml file of the server.

The URL address contains the config in the values folder. the purpose of the xml file is that when the URL needs to be changed, you do not need to modify it in the code. You only need to modify the configuration file to reduce development costs. The configuration information is as follows:

<?xml version="1.0" encoding="utf-8"?><resources>    <string name="serverurl">http:<resources>

 

  

 

                   UpdateInfo getUpdateInfo(InputStream is)                   XmlPullParser parser=                  parser.setInput(is,"utf-8"                  UpdateInfo info=                   type=                  (type!=             (type==XmlPullParser.START_TAG){                 ("version"                                                                        String version=                  } ("description"                     String description=                  } ("apkurl"                     String apkurl=                type=            }

 

  

 

Because the networking process is generally a time-consuming operation, to avoid ANR exceptions, we open a subthread in the main thread to check the version number online. In this case, we should also configure the network permission information in the list file:

<uses-permission android:name="android.permission.INTERNET"/>

 

 

                                                URL url=         File file=             FileOutputStream fos=             HttpURLConnection conn=                          conn.setRequestMethod("GET"                          conn.setConnectTimeout(5000                           max=                                        InputStream is=                          [] buf= [1024              len=0              process=0             ((len=is.read(buf))!=-1                 fos.write(buf, 0                                  process+=                                   Thread.sleep(30                                                    }                                   }

                                              urlpath.substring(urlpath.lastIndexOf("/")+1                           }

<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

 

                                 Intent intent=         intent.setAction("android.intent.action.VIEW");         intent.addCategory("android.intent.category.DEFAULT"          intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");         startActivity(intent);

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.