public void checkMessage(Intent intent)
        {
            if (null != intent)
            {
                if (intent.HasExtra(PushManager.PushReceiveEvent))
                {
                    doOnMessageReceive(intent.Extras.GetString(PushManager.PushReceiveEvent));
                }
                else if (intent.HasExtra(PushManager.RegisterEvent))
                {
                    doOnRegistered(intent.Extras.GetString(PushManager.RegisterEvent));
                }
                else if (intent.HasExtra(PushManager.UnregisterEvent))
                {
                    doOnUnregisteredError(intent.Extras.GetString(PushManager.UnregisterEvent));
                }
                else if (intent.HasExtra(PushManager.RegisterErrorEvent))
                {
                    doOnRegisteredError(intent.Extras.GetString(PushManager.RegisterErrorEvent));
                }
                else if (intent.HasExtra(PushManager.UnregisterErrorEvent))
                {
                    doOnUnregistered(intent.Extras.GetString(PushManager.UnregisterErrorEvent));
                }

                resetIntentValues();
            }
        }
        public override void OnActivityResult(int requestCode, int resultCode, Android.Content.Intent data)
        {
            mProgressDialog.Hide();

            // retrieve the error code, if available
            int errorCode = -1;

            if (data != null)
            {
                errorCode = data.GetIntExtra(WalletConstants.ExtraErrorCode, -1);
            }

            switch (requestCode)
            {
            case REQUEST_CODE_RESOLVE_ERR:
                if (resultCode == (int)Result.Ok)
                {
                    mGoogleApiClient.Connect();
                }
                else
                {
                    handleUnrecoverableGoogleWalletError(errorCode);
                }
                break;

            case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET:
                switch (resultCode)
                {
                case (int)Result.Ok:
                    if (data.HasExtra(WalletConstants.ExtraFullWallet))
                    {
                        FullWallet fullWallet =
                            data.GetParcelableExtra(WalletConstants.ExtraFullWallet).JavaCast <FullWallet> ();
                        // the full wallet can now be used to process the customer's payment
                        // send the wallet info up to server to process, and to get the result
                        // for sending a transaction status
                        fetchTransactionStatus(fullWallet);
                    }
                    else if (data.HasExtra(WalletConstants.ExtraMaskedWallet))
                    {
                        // re-launch the activity with new masked wallet information
                        mMaskedWallet = data.GetParcelableExtra(WalletConstants.ExtraMaskedWallet).JavaCast <MaskedWallet> ();
                        mActivityLaunchIntent.PutExtra(Constants.EXTRA_MASKED_WALLET, mMaskedWallet);

                        StartActivity(mActivityLaunchIntent);
                    }
                    break;

                case (int)Result.Canceled:
                    // nothing to do here
                    break;

                default:
                    handleError(errorCode);
                    break;
                }
                break;
            }
        }
 /**
  * If the confirmation page encounters an error it can't handle, it will send the customer back
  * to this page.  The intent should include the error code as an {@code int} in the field
  * {@link WalletConstants#EXTRA_ERROR_CODE}.
  */
 protected override void OnNewIntent(Android.Content.Intent intent)
 {
     if (intent.HasExtra(WalletConstants.ExtraErrorCode))
     {
         int errorCode = intent.GetIntExtra(WalletConstants.ExtraErrorCode, 0);
         HandleError(errorCode);
     }
 }
示例#4
0
        private long MAX_FILE_SIZE = 1048576; // 1MB

        #endregion Fields

        #region Methods

        protected void onActivityResult(int requestCode, int resultCode, Intent  data)
        {
            TLog.d(TAG, "onActivityResult called");
            Android.Net.Uri uri = null;
            if(data != null && data.HasExtra("uri"))
                uri = Android.Net.Uri.Parse(data.GetStringExtra("uri"));

            // view new note
            Intent i = new Intent(Intent.ActionView, uri, this, typeof(Tomdroid));
            i.PutExtra("view_note", true);
            i.AddFlags(ActivityFlags.ClearTop);
            StartActivity(i);
            Finish();
        }
示例#5
0
        protected override void OnNewIntent(Android.Content.Intent intent)
        {
            base.OnNewIntent(intent);

            // Get the barcode options from the intent
            var barcodeFormat = ZXing.BarcodeFormat.QR_CODE;

            if (intent.HasExtra("FORMAT"))
            {
                System.Enum.TryParse <ZXing.BarcodeFormat> (intent.GetStringExtra("FORMAT"), out barcodeFormat);
            }

            var barcodeValue = string.Empty;

            if (intent.HasExtra("VALUE"))
            {
                barcodeValue = intent.GetStringExtra("VALUE") ?? string.Empty;
            }

            var barcodeUrl = string.Empty;

            if (intent.HasExtra("URL"))
            {
                barcodeUrl = intent.GetStringExtra("URL") ?? string.Empty;
            }

            // Can set from a URL or generate from a format/value
            if (!string.IsNullOrEmpty(barcodeUrl))
            {
                SetBarcode(barcodeUrl);
            }
            else if (!string.IsNullOrEmpty(barcodeValue))
            {
                SetBarcode(barcodeFormat, barcodeValue);
            }
        }
示例#6
0
        public override void OnReceive(Context context, Intent intent)
        {
            sqlite3_shutdown();
            SqliteConnection.SetConfig(SQLiteConfig.Serialized);
            sqlite3_initialize();

            // If you got a location extra, use it
            Location loc = (Location)intent.GetParcelableExtra(LocationManager.KeyLocationChanged);
            if (loc != null) {
                OnLocationReceived(context, loc);
                return;
            }
            // If you get here, something else has happened
            if (intent.HasExtra(LocationManager.KeyProviderEnabled)) {
                bool enabled = intent.GetBooleanExtra(LocationManager.KeyProviderEnabled, false);
                OnProviderEnabledChanged(context, enabled);
            }
        }
示例#7
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (RegistroActivity.REQUEST_CODE == requestCode)
            {
                if ((data == null) || (!data.HasExtra(RegistroActivity.LISTA_SELOS)))
                    return;

                arquivo.Selos = WrapperSelo.DesserializarLista(
                    data.GetStringExtra(RegistroActivity.LISTA_SELOS));
                arquivo.Salvar();

                adapter.Selos = arquivo.Selos;
                adapter.NotifyDataSetChanged();

            }
        }
示例#8
0
        /// <summary>
        /// Forwards <c>OnActivityResult</c> to the <c>CardIO</c> plugin. This is a must!
        /// </summary>
        /// <param name="requestCode">Request code</param>
        /// <param name="resultCode">Result code</param>
        /// <param name="data">Intent data</param>
        public static void ForwardActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (requestCode == ScanActivityResultCode)
            {
                if (data != null && data.HasExtra(CardIOActivity.ExtraScanResult))
                {
                    CreditCard scanResult = (CreditCard)data.GetParcelableExtra(CardIOActivity.ExtraScanResult);
                    
                    _currentScan._result = new CardIOResult
                    {
                        CreditCardType = scanResult.CardType.ToPclCardType(),
                        CardNumber = scanResult.CardNumber,
                        Cvv = scanResult.Cvv,
                        Expiry = new DateTime(scanResult.ExpiryYear, scanResult.ExpiryMonth, 1),
                        PostalCode = scanResult.PostalCode,
                        Success = true
                    };
                }
                else
                    _currentScan._result = new CardIOResult { Success = false };

                _currentScan._finished = true;
            }
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            Kp2aLog.Log("base.onAR");
            base.OnActivityResult(requestCode, resultCode, data);
            if ((requestCode == RequestCodeFileStorageSelectionForPrimarySelect) || ((requestCode == RequestCodeFileStorageSelectionForCopyToWritableLocation)))
            {
                int browseRequestCode = RequestCodeFileBrowseForOpen;
                if (requestCode == RequestCodeFileStorageSelectionForCopyToWritableLocation)
                {
                    browseRequestCode = RequestCodeFileFileBrowseForWritableLocation;
                }

                if (resultCode == ExitFileStorageSelectionOk)
                {

                    string protocolId = data.GetStringExtra("protocolId");

                    if (protocolId == "androidget")
                    {
                        ShowAndroidBrowseDialog(browseRequestCode, false, false);
                    }
                    else if (protocolId == "content")
                    {
                        ShowAndroidBrowseDialog(browseRequestCode, browseRequestCode == RequestCodeFileFileBrowseForWritableLocation, true);
                    }
                    else
                    {
                        bool isForSave = (requestCode == RequestCodeFileStorageSelectionForPrimarySelect) ?
                                             IsStorageSelectionForSave : true;

                        StartSelectFile(isForSave, browseRequestCode, protocolId);

                    }

                }
                else
                {
                    ReturnCancel();
                }

            }

            if ((requestCode == RequestCodeFileBrowseForOpen) || (requestCode == RequestCodeFileFileBrowseForWritableLocation))
            {
                if (resultCode == (Result)FileStorageResults.FileChooserPrepared)
                {
                    IOConnectionInfo ioc = new IOConnectionInfo();
                    SetIoConnectionFromIntent(ioc, data);
                    bool isForSave = (requestCode == RequestCodeFileFileBrowseForWritableLocation) ?
                                         true : IsStorageSelectionForSave;

                    StartFileChooser(ioc.Path, requestCode, isForSave);

                    return;
                }
                if ((resultCode == Result.Canceled) && (data != null) && (data.HasExtra("EXTRA_ERROR_MESSAGE")))
                {
                    ShowToast(data.GetStringExtra("EXTRA_ERROR_MESSAGE"));
                }

                if (resultCode == Result.Ok)
                {
                    Kp2aLog.Log("FileSelection returned "+data.DataString);
                    //TODO: don't try to extract filename if content URI
                    string filename = IntentToFilename(data);
                    Kp2aLog.Log("FileSelection returned filename " + filename);
                    if (filename != null)
                    {
                        if (filename.StartsWith("file://"))
                        {
                            filename = filename.Substring(7);
                            filename = URLDecoder.Decode(filename);
                        }

                        IOConnectionInfo ioc = new IOConnectionInfo
                            {
                                Path = filename
                            };

                        IocSelected(ioc, requestCode);
                    }
                    else
                    {
                        if (data.Data.Scheme == "content")
                        {
                            if ((int) Build.VERSION.SdkInt >= 19)
                            {
                                //try to take persistable permissions
                                try
                                {
                                    Kp2aLog.Log("TakePersistableUriPermission");
                                    var takeFlags = data.Flags
                                            & (ActivityFlags.GrantReadUriPermission
                                            | ActivityFlags.GrantWriteUriPermission);
                                    this.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags);
                                }
                                catch (Exception e)
                                {
                                    Kp2aLog.Log(e.ToString());
                                }

                            }

                            IocSelected(IOConnectionInfo.FromPath(data.DataString), requestCode);

                        }
                        else
                        {
                            ShowInvalidSchemeMessage(data.DataString);
                            ReturnCancel();
                        }

                    }
                }
                else
                {
                    ReturnCancel();
                }

            }
        }
示例#10
0
文件: Util.cs 项目: pythe/wristpass
        public static string GetFilenameFromInternalFileChooser(Intent data, Context ctx)
        {
            #if !EXCLUDE_FILECHOOSER
            string EXTRA_RESULTS = "group.pals.android.lib.ui.filechooser.FileChooserActivity.results";
            if (data.HasExtra(EXTRA_RESULTS))
            {
                IList uris = data.GetParcelableArrayListExtra(EXTRA_RESULTS);
                Uri uri = (Uri) uris[0];
                {
                    return Group.Pals.Android.Lib.UI.Filechooser.Providers.BaseFileProviderUtils.GetRealUri(ctx, uri).ToString();
                }
            }

            #endif
            return null;
        }
示例#11
0
        bool OnHandleIntent(Intent intent)
        {
            if (intent != null) {
                if (intent.Action == FinishTripAction)
                    FinishTrip ();
                else if (ActivityRecognitionResult.HasResult (intent))
                    HandleActivityRecognition (intent);
                else if (intent.HasExtra (LocationClient.KeyLocationChanged))
                    HandleLocationUpdate (intent);
            }

            return currentBikingState != BikingState.NotBiking;
        }
示例#12
0
        public override StartCommandResult OnStartCommand(Android.Content.Intent intent, StartCommandFlags flags, int startId)
        {
            bool portChanged = false;

            if (intent.HasExtra("UDPPort"))
            {
                int port = intent.GetIntExtra("UDPPort", Settings.Settings.Instance.UdpPort);
                if (port != Settings.Settings.Instance.UdpPort)
                {
                    Settings.Settings.Instance.UdpPort = port;
                    Settings.Settings.Instance.Write(ApplicationContext);
                    portChanged = true;
                }
            }
            if (!mIsInitialized)
            {
                System.Threading.ThreadPool.QueueUserWorkItem((state) => {
                    lock (lockObject)
                    {
                        try
                        {
                            Initialize();
                            UpdateNotification(true);
                        }
                        catch (Exception ex)
                        {
                            LogException(ex);
                            ShowToast(ex.Message);
                        }
                    }
                });
                mIsInitialized = true;
            }
            else if (portChanged)
            {
                System.Threading.ThreadPool.QueueUserWorkItem((state) => {
                    lock (lockObject)
                    {
                        try
                        {
                            Shutdown();
                            Initialize();
                            UpdateNotification(true);
                        }
                        catch (Exception ex)
                        {
                            LogException(ex);
                            ShowToast(ex.Message);
                        }
                    }
                });
            }
            else
            {
                System.Threading.ThreadPool.QueueUserWorkItem((state) => {
                    lock (lockObject)
                    {
                        try
                        {
                            if (m_Network.ClientConnected)
                            {
                                m_Network.DisconnectClient(true);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogException(ex);
                            ShowToast(ex.Message);
                        }
                    }
                });
            }
            return(StartCommandResult.Sticky);
        }
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent.HasExtra (EXTRA_HIDE_OVERLAYS)) {
         OnHideOverlays (intent.GetBooleanExtra (EXTRA_HIDE_OVERLAYS, false));
     }
 }
 public void HandleCommand(Intent intent)
 {
     if (intent.HasExtra(PING_SERVICE_EXTRA)) {
         PerformPing();
     }
 }
示例#15
0
        protected override void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);

            //this method is called from the NfcOtpActivity's startActivity() if the activity is already running
            //note: it's not called in other cases because OnNewIntent requires the activity to be on top already
            //which is never the case when started from another activity (in the same task).
            //NfcOtpActivity sets the ClearTop flag to get OnNewIntent called.
            if ((intent != null) && (intent.HasExtra(Intents.OtpExtraKey)))
            {
                string otp = intent.GetStringExtra(Intents.OtpExtraKey);

                if (this.KeyProviderType == KeyProviders.Otp)
                {
                    _keepPasswordInOnResume = true;

                    if (_otpInfo == null)
                    {
                        //Entering OTPs not yet initialized:
                        _pendingOtps.Add(otp);
                        UpdateKeyProviderUiState();
                    }
                    else
                    {
                        //Entering OTPs is initialized. Write OTP into first empty field:
                        bool foundEmptyField = false;
                        foreach (int otpId in _otpTextViewIds)
                        {
                            EditText otpEdit = FindViewById<EditText>(otpId);
                            if ((otpEdit.Visibility == ViewStates.Visible) && String.IsNullOrEmpty(otpEdit.Text))
                            {
                                otpEdit.Text = otp;
                                foundEmptyField = true;
                                break;
                            }
                        }
                        //did we find a field?
                        if (!foundEmptyField)
                        {
                            Toast.MakeText(this, GetString(Resource.String.otp_discarded_no_space), ToastLength.Long).Show();
                        }
                    }

                    Spinner passwordModeSpinner = FindViewById<Spinner>(Resource.Id.password_mode_spinner);
                    if (passwordModeSpinner.SelectedItemPosition != (int)KeyProviders.Otp)
                    {
                        passwordModeSpinner.SetSelection((int)KeyProviders.Otp);
                    }
                }
                else
                {
                    //assume the key should be used as static password
                    FindViewById<EditText>(Resource.Id.password).Text += otp;
                }

            }
        }
示例#16
0
        protected void onActivityResult(int requestCode, int resultCode, Intent  data)
        {
            TLog.d(TAG, "onActivityResult called with result {0}", resultCode);

            // returning from file picker
            if(data != null && data.HasExtra(FilePickerActivity.EXTRA_FILE_PATH)) {
                // Get the file path
                File f = new File(data.GetStringExtra(FilePickerActivity.EXTRA_FILE_PATH));
                Uri noteUri = Uri.FromFile(f);
                Intent intent = new Intent(this, typeof(Receive));
                intent.Data = noteUri;
                StartActivity(intent);
            }
            else { // returning from sync conflict
                SyncService currentService = SyncManager.getInstance().getCurrentService();
                currentService.resolvedConflict(requestCode);
            }
        }