public override void OnReceive(Context context, Intent intent) { var action = intent.Action; if (DownloadManager.ActionDownloadComplete.Equals(action)) { var downloadId = intent.GetLongExtra(DownloadManager.ExtraDownloadId, 0); var query = new DownloadManager.Query(); query.SetFilterById(_webViewClient.Enqueue); var c = _webViewClient.Dm.InvokeQuery(query); if (c.MoveToFirst()) { var columnIndex = c.GetColumnIndex(DownloadManager.ColumnStatus); if ((int) Android.App.DownloadStatus.Successful == c.GetInt(columnIndex)) { var view = (ImageView) _webViewClient.Controls.Activity.FindViewById(12); var uriString = c.GetString(c.GetColumnIndex(DownloadManager.ColumnLocalUri)); view.SetImageURI(Android.Net.Uri.Parse(uriString)); } var list = new List<string>(); var columnNames = c.GetColumnNames(); for (var i = 0; i < c.ColumnCount; i++) { list.Add(columnNames[i]); } columnIndex = c.GetColumnIndex(DownloadManager.ColumnReason); var s = c.GetString(columnIndex); _webViewClient.Controls.Title.Text = s; } } }
/// <summary> /// This is the entry point for all asynchronous messages sent from Android Market to /// the application. This method forwards the messages on to the /// <seealso cref="BillingService"/>, which handles the communication back to Android Market. /// The <seealso cref="BillingService"/> also reports state changes back to the application through /// the <seealso cref="ResponseHandler"/>. /// </summary> public override void OnReceive(Context context, Intent intent) { string action = intent.Action; if (Consts.ACTION_PURCHASE_STATE_CHANGED.Equals(action)) { string signedData = intent.GetStringExtra(Consts.INAPP_SIGNED_DATA); string signature = intent.GetStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(context, signedData, signature); } else if (Consts.ACTION_NOTIFY.Equals(action)) { string notifyId = intent.GetStringExtra(Consts.NOTIFICATION_ID); if (Consts.DEBUG) { Log.Info(TAG, "notifyId: " + notifyId); } notify(context, notifyId); } else if (Consts.ACTION_RESPONSE_CODE.Equals(action)) { long requestId = intent.GetLongExtra(Consts.INAPP_REQUEST_ID, -1); int responseCodeIndex = intent.GetIntExtra(Consts.INAPP_RESPONSE_CODE, (int)Consts.ResponseCode.RESULT_ERROR); checkResponseCode(context, requestId, responseCodeIndex); } else { Log.Warn(TAG, "unexpected action: " + action); } }
/** * The {@link BillingReceiver} sends messages to this service using intents. * Each intent has an action and some extra arguments specific to that action. * @param intent the intent containing one of the supported actions * @param startId an identifier for the invocation instance of this service */ public void handleCommand(Intent intent, int startId) { string action = intent.Action; if (Consts.DEBUG) Log.Info(TAG, "handleCommand() action: " + action); if (Consts.ACTION_CONFIRM_NOTIFICATION.Equals(action)) { string[] notifyIds = intent.GetStringArrayExtra(Consts.NOTIFICATION_ID); Execute(new ConfirmNotifications(startId, notifyIds)); } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.Equals(action)) { string notifyId = intent.GetStringExtra(Consts.NOTIFICATION_ID); Execute(new GetPurchaseInformation(startId, new string[] { notifyId })); } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.Equals(action)) { string signedData = intent.GetStringExtra(Consts.INAPP_SIGNED_DATA); string signature = intent.GetStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(startId, signedData, signature); } else if (Consts.ACTION_RESPONSE_CODE.Equals(action)) { long requestId = intent.GetLongExtra(Consts.INAPP_REQUEST_ID, -1); int responseCodeIndex = intent.GetIntExtra(Consts.INAPP_RESPONSE_CODE, (int)Consts.ResponseCode.RESULT_ERROR); Consts.ResponseCode responseCode = (Consts.ResponseCode)responseCodeIndex; checkResponseCode(requestId, responseCode); } }
private void restoreTransactions(Intent intent, int startId) { string packageName = PackageName; long nonce = intent.GetLongExtra(EXTRA_NONCE, 0); RestoreTransactions request = new RestoreTransactions(packageName, startId); request.setNonce(nonce); runRequestOrQueue(request); }
private void getPurchaseInformation(Intent intent, int startId) { string packageName = PackageName; long nonce = intent.GetLongExtra(EXTRA_NONCE, 0); string[] notifyIds = intent.GetStringArrayExtra(EXTRA_NOTIFY_IDS); GetPurchaseInformation request = new GetPurchaseInformation(packageName, startId, notifyIds); request.setNonce(nonce); runRequestOrQueue(request); }