學習手機安全衛士項目源碼記錄

來源:互聯網
上載者:User

 

 


 

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

 

   

 

 

   

 

            AlertDialog.Builder builder= Builder(                            builder.setTitle("升級提示"                  builder.setMessage(""                  builder.setPositiveButton("升級",                  onClick(DialogInterface dialog,                             builder.setNegativeButton("取消",                 onClick(DialogInterface dialog,        }

 

 

 

  String serverurl=getResources().getString(R.string.serverurl):得到訪問服務端配置資訊(即服務端的info.xml檔案)的URL地址。

  該URL地址存在values檔案夾下的config.xml檔案中,目的在於,當這個URL需要變更時,不需要在代碼中進行修改,只需要修改這個設定檔即可實現,降低了開發成本。配置資訊如下:

<?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=            }

 

  

 

  由於連網的過程是一般是一個耗時的操作,為了避免出現ANR異常,我們在主線程中開啟一個子線程用於連網核對版本號碼資訊。此時我們還應該在資訊清單檔中配置網路許可權的資訊: 

<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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.