using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; using System.Threading; using Java.Lang; //using JiaHang.OA.SHCGAPP.Class; namespace com.hdl.on { [Activity(Label = "ÏÂÔØ")] public class AppUpgradeActivity : Activity { private static int _Progress = 0; private static TextView _Text = null; private static ProgressBar _ProgressBar = null; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AppUpgrate); //ImageView icon = FindViewById(Resource.Id.app_upgrate_icon); //icon.SetImageResource(Resource.Drawable.Apps); if (_Text == null) _Text = FindViewById(Resource.Id.app_upgrate_text); if (_ProgressBar == null) _ProgressBar = FindViewById(Resource.Id.app_upgrate_progressbar); //Ò첽ˢнø¶ÈÌõµÄÏÔʾÐÅÏ¢ new MyAsync().Execute(this); //Common.InstallNewApk(this); } private class MyAsync : AsyncTask { private Activity _Activity = null; protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params) { _Activity = (Activity)@params[0]; while (_Progress != 100) { _Progress = AppUpgradeService._CurrentProgress; System.Threading.Thread.Sleep(500); //ÐÝÃß0.5Ãë ·ÀÖ¹ÄÚ´æ³Ô½ô PublishProgress(_Progress); } return null; } protected override void OnProgressUpdate(params Java.Lang.Object[] values) { //base.OnProgressUpdate(values); _Text.Text = "ÕýÔÚÏÂÔØ¸üУ¬µ±Ç°½ø¶ÈΪ£º" + _Progress + "%"; _ProgressBar.Progress = _Progress; } protected override void OnPostExecute(Java.Lang.Object result) { _Text.Text = "ÏÂÔØÍê±Ï£¬µã»÷°²×°£¡"; _ProgressBar.Click += (sender, e) => { //Common.InstallNewApk(_Activity); Intent ite = new Intent (Intent.ActionView); string RootPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/"; string filePath = RootPath + "UpdateApk.apk"; var uriPath = Android.Net.Uri.Parse (@"file://" + filePath); ite.SetDataAndType (uriPath, @"application/vnd.android.package-archive"); ite.SetFlags (ActivityFlags.NewTask);//Õâ¾äºÜ¹Ø¼ü£¬Ã»ÓÐÕâ¾ä°²×°Íê³Éºó²»»áµ¯³ö¡°Íê³É¡±ºÍ¡°´ò¿ª¡±µÄ¶Ô»°¿ò£» _Activity.StartActivity (ite); }; } } } }