private void DeliverResultToReceiver(Result resultCode, string message) { var bundle = new Bundle(); bundle.PutString(Constants.RESULT_DATA_KEY, message); _receiver.Send(resultCode, bundle); }
void DeliverResultToReceiver(Result resultCode, string message) { var bundle = new Bundle(); bundle.PutString(Constants.ResultDataKey, message); mReceiver.Send(resultCode, bundle); }
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) { var resultData = new Bundle(); resultData.PutStringArray(PermissionsHelper.KeyPermissions, permissions); resultData.PutIntArray(PermissionsHelper.KeyGrants, grantResults.Select(gr => (int)gr).ToArray()); _resultReceiver.Send((Result)_requestCode, resultData); base.OnRequestPermissionsResult(requestCode, permissions, grantResults); Finish(); }
public async void Run() { try { //Toast.MakeText(Application.Context, "Started", ToastLength.Short).Show(); if (ResultSender == null) { try { SqLiteDatabase dbDatabase = new SqLiteDatabase(); var login = dbDatabase.Get_data_Login_Credentials(); (int apiStatus, var respond) = await RequestsAsync.Chat.GetConversationListAsync("15", "0"); if (apiStatus != 200 || !(respond is GetConversationListObject result)) { // Methods.DisplayReportResult(Activity, respond); } else { //Toast.MakeText(Application.Context, "ResultSender 1 \n" + data, ToastLength.Short).Show(); if (result.Data.Count > 0) { ListUtils.ChatList = new ObservableCollection <GetConversationListObject.DataConversation>(result.Data); //Insert All data users to database dbDatabase.InsertOrReplaceLastChatTable(ListUtils.ChatList); } } dbDatabase.Dispose(); } catch (Exception e) { Console.WriteLine(e); // Toast.MakeText(Application.Context, "Exception " + e, ToastLength.Short).Show(); } } else { (int apiStatus, var respond) = await RequestsAsync.Chat.GetConversationListAsync("15", "0"); if (apiStatus != 200 || !(respond is GetConversationListObject result)) { // Methods.DisplayReportResult(Activity, respond); } else { var b = new Bundle(); b.PutString("Json", JsonConvert.SerializeObject(result)); ResultSender.Send(0, b); //Toast.MakeText(Application.Context, "ResultSender 2 \n" + data, ToastLength.Short).Show(); Console.WriteLine("Allen Post + started"); } } MainHandler.PostDelayed(new ApiPostUpdaterHelper(Activity, MainHandler, ResultSender), AppSettings.RefreshChatActivitiesSeconds); } catch (Exception e) { //Toast.MakeText(Application.Context, "ResultSender failed", ToastLength.Short).Show(); MainHandler.PostDelayed(new ApiPostUpdaterHelper(Activity, MainHandler, ResultSender), AppSettings.RefreshChatActivitiesSeconds); Console.WriteLine(e); Console.WriteLine("Allen Post + failed"); } }
public async void Run() { try { //Toast.MakeText(Application.Context, "Started", ToastLength.Short).Show(); if (Methods.AppLifecycleObserver.AppState == Methods.AppLifecycleObserver.AppLifeState.Background) { try { SqLiteDatabase dbDatabase = new SqLiteDatabase(); var login = dbDatabase.Get_data_Login(); Console.WriteLine(login); if (string.IsNullOrEmpty(Current.AccessToken)) { return; } (int apiStatus, var respond) = await RequestsAsync.Messages.GetChats("15", "0"); if (apiStatus != 200 || !(respond is GetChatsObject result)) { // Methods.DisplayReportResult(Activity, respond); } else { //Toast.MakeText(Application.Context, "ResultSender 1 \n" + data, ToastLength.Short).Show(); if (result.data.Count > 0) { ListUtils.ChatList = new ObservableCollection <GetChatsObject.Data>(result.data); //Insert All data users to database dbDatabase.InsertOrReplaceLastChatTable(ListUtils.ChatList); } } dbDatabase.Dispose(); } catch (Exception e) { Console.WriteLine(e); // Toast.MakeText(Application.Context, "Exception " + e, ToastLength.Short).Show(); } } else { (int apiStatus, var respond) = await RequestsAsync.Messages.GetChats("15", "0"); if (apiStatus != 200 || !(respond is GetChatsObject result)) { // Methods.DisplayReportResult(Activity, respond); } else { var b = new Bundle(); b.PutString("Json", JsonConvert.SerializeObject(result)); ResultSender.Send(0, b); //Toast.MakeText(Application.Context, "ResultSender 2 \n" + data, ToastLength.Short).Show(); Console.WriteLine("Allen Post + started"); } } MainHandler.PostDelayed(new ApiPostUpdaterHelper(Activity, new Handler(), ResultSender), AppSettings.RefreshChatActivitiesSeconds); } catch (Exception e) { //Toast.MakeText(Application.Context, "ResultSender failed", ToastLength.Short).Show(); MainHandler.PostDelayed(new ApiPostUpdaterHelper(Activity, new Handler(), ResultSender), AppSettings.RefreshChatActivitiesSeconds); Console.WriteLine(e); Console.WriteLine("Allen Post + failed"); } }
protected override void OnHandleIntent(Intent intent) { Log.Debug(TAG, "onHandleIntent(intent=" + intent.ToString() + ")"); ResultReceiver receiver = (ResultReceiver)intent.GetParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) { receiver.Send(StatusRunning, Bundle.Empty); } Context context = this; var prefs = GetSharedPreferences(Prefs.IOSCHED_SYNC, FileCreationMode.Private); int localVersion = prefs.GetInt(Prefs.LOCAL_VERSION, VERSION_NONE); try { // Bulk of sync work, performed by executing several fetches from // local and online sources. long startLocal = Java.Lang.JavaSystem.CurrentTimeMillis(); bool localParse = localVersion < VERSION_CURRENT; Log.Debug(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT); if (localParse) { // Load static local data mLocalExecutor.Execute(Resource.Xml.blocks, new LocalBlocksHandler()); mLocalExecutor.Execute(Resource.Xml.rooms, new LocalRoomsHandler()); mLocalExecutor.Execute(Resource.Xml.tracks, new LocalTracksHandler()); mLocalExecutor.Execute(Resource.Xml.search_suggest, new LocalSearchSuggestHandler()); mLocalExecutor.Execute(Resource.Xml.sessions, new LocalSessionsHandler()); // Parse values from local cache first, since spreadsheet copy // or network might be down. // mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler()); // mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler()); // mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler()); // Save local parsed version prefs.Edit().PutInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).Commit(); } Log.Debug(TAG, "local sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startLocal) + "ms"); // Always hit remote spreadsheet for any updates long startRemote = Java.Lang.JavaSystem.CurrentTimeMillis(); // mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor)); Log.Debug(TAG, "remote sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startRemote) + "ms"); } catch (Exception e) { Log.Error(TAG, "Problem while syncing", e); if (receiver != null) { // Pass back error to surface listener Bundle bundle = new Bundle(); bundle.PutString(Intent.ExtraText, e.ToString()); receiver.Send(StatusError, bundle); } } // Announce success to any surface listener Log.Debug(TAG, "sync finished"); if (receiver != null) { receiver.Send(StatusFinished, Bundle.Empty); } }