예제 #1
0
        private Intent GetFileServiceIntent(string action, IParcelable uri)
        {
            var intent = AndroidUtil.CreateExplicitFromImplicitIntent(this, new Intent(action));

            switch (action)
            {
            case FileBoundService.ActionFeedback:
            case FileBoundService.ActionZipLogFiles:
                _compressFileName = Path.Combine(_tmpFolder,
                                                 string.Format("log_{0}_{1:yyyyMMddHHmmss}.zip", _productName, DateTime.Now));
                intent.PutExtra(FileBoundService.ExtraZipFileName, _compressFileName);
                intent.PutExtra(FileBoundService.ExtraLogFileName, AppSettings.Default.LogFileName);
                intent.PutExtra(FileBoundService.ExtraComment, _versionFull);
                break;

            case FileBoundService.ActionExportLog:
                intent.PutExtra(FileBoundService.ExtraZipFileName, _compressFileName);
                if (uri != null)
                {
                    intent.PutExtra(Intent.ExtraStream, uri);
                }
                break;

            default:
                throw new NotImplementedException(action);
            }

            return(intent);
        }
예제 #2
0
        protected override void OnResume()
        {
            base.OnResume();

            ValidateServiceReceiver();
            var intentFilter = new IntentFilter(FileBoundService.ActionFeedback)
            {
                Priority = (int)IntentFilterPriority.HighPriority
            };

            intentFilter.AddAction(FileBoundService.ActionZipLogFiles);
            intentFilter.AddAction(FileBoundService.ActionExportLog);

            RegisterReceiver(_serviceReceiver, intentFilter);

            ServiceConnectionDispose();
            _serviceConnection = new ServiceConnection(this);

            var serviceIntent = AndroidUtil.CreateExplicitFromImplicitIntent(this,
                                                                             new Intent(FileBoundService.ActionZipLogFiles));

            BindService(serviceIntent, _serviceConnection, Bind.AutoCreate);

            try
            {
                StartFileService();
            }
            catch (Exception ex)
            {
                ShowProgressbar(false);
                ShowError(ex, Resource.String.InternalError);
            }
        }