private void Toolbar_MenuItemClick(object sender, Toolbar.MenuItemClickEventArgs e) { // throw new NotImplementedException(); int id = (int)e.Item.ItemId; Intent activity; Bundle bundle; switch (id) { case Resource.Id.navigation_home: activity = new Intent(this, typeof(HistoriqueActivity)); activity.PutExtra("NameFile", backingFile_historique); StartActivity(activity); break; case Resource.Id.navigation_dashboard: activity = new Intent(this, typeof(CoordonnéeActivity)); bundle = new Bundle(); bundle.PutByteArray("Data", Coordonnées_Data.ToByte()); activity.PutExtra("Data", bundle); StartActivity(activity); break; case Resource.Id.navigation_notifications: ResetHistorique(); break; } }
/* * /// <summary> * /// Gets the profile information. * /// </summary> * /// <param name="token">The token.</param> * /// <returns>Task<UserProfile>.</returns> * public async Task<UserProfile> GetProfileInfo(string token) * { * UserProfile userProfile; * var taskCompletionSource = new TaskCompletionSource<UserProfile>(); * var parameters = new Bundle(); * parameters.PutString("fields", "name,email,picture.type(large)"); * var client = new WebClient(); * var response = new Response() * { * HandleSuccess = (respose) => * { * userProfile = new UserProfile * { * Name = respose.JSONObject.GetString("name"), * Email = respose.JSONObject.GetString("email"), * ProfilePictureUrl = * respose.JSONObject.GetJSONObject("picture").GetJSONObject("data").GetString("url") * }; * * var pictureUrl = respose.JSONObject.GetJSONObject("picture").GetJSONObject("data").GetString("url"); * * // Download user profile picture * var pictureData = client.DownloadData(pictureUrl); * userProfile.ProfilePicture = pictureData; * * * taskCompletionSource.SetResult(userProfile); * } * }; * * * var graphRequest = new GraphRequest(AccessToken.CurrentAccessToken, * "/" + AccessToken.CurrentAccessToken.UserId, parameters, HttpMethod.Get, response); * graphRequest.ExecuteAsync(); * return await taskCompletionSource.Task; * } */ public async Task <bool> PostToFacebook(string statusUpdate, byte[] media) { if (AccessToken.CurrentAccessToken == null || string.IsNullOrEmpty(AccessToken.CurrentAccessToken.UserId)) { return(false); } var taskCompletionSource = new TaskCompletionSource <bool>(); var parameters = new Bundle(); parameters.PutString("message", statusUpdate); parameters.PutByteArray("picture", media); var response = new Response() { HandleSuccess = (respose) => { taskCompletionSource.SetResult(true); } }; var graphRequest = new GraphRequest(AccessToken.CurrentAccessToken, media != null ? "/me/photos" : "/me/feed", parameters, HttpMethod.Post, response); graphRequest.ExecuteAsync(); return(await taskCompletionSource.Task); }
private void ImageView_Click(object sender, EventArgs e) { if (entrega != null) { if (entrega.Image != null) { Bundle bundle = new Bundle(); bundle.PutByteArray("imagem", entrega.Image); Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction(); FragmentImageView dialog = new FragmentImageView(); dialog.Arguments = bundle; dialog.Show(transaction, "dialog"); } } else { if (bytes != null) { Bundle bundle = new Bundle(); bundle.PutByteArray("imagem", bytes); Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction(); FragmentImageView dialog = new FragmentImageView(); dialog.Arguments = bundle; dialog.Show(transaction, "dialog"); } } }
private void ProcessInitRequest(Message msg, Message replyMsg) { string appId = msg.Data.GetString("AppId", null); if (string.IsNullOrEmpty(appId)) { return; } else { Bundle bundle = new Bundle(); var SessionId = Guid.NewGuid().ToString(); Random rand = new Random(); for (int i = 0; i < 5; i++) { int p = rand.Next(SessionId.Length - 1); SessionId = SessionId.Remove(p, 1); } SessionId = SessionId.Replace("-", ""); SaveSessionId(_vdmService, appId, SessionId); bundle.PutString("SessionId", SessionId.ToString()); _db.EmptyDb(appId); byte[] bytes = _db.GetByteArray(); bundle.PutByteArray("Database", bytes); bundle.PutString("DestinationPath", _db.GetDBImportPath()); replyMsg.Data = bundle; } }
private void OpenColorSelector(object sender, EventArgs e) { var intent = new Intent(this, typeof(ColorSelectActivity)); Bundle b = new Bundle(); b.PutByteArray("color", new byte[] { color.R, color.G, color.B }); intent.PutExtra("color", b); StartActivity(intent); }
public static CrimeFragment NewInstance(Guid crimeId) { var args = new Bundle(); args.PutByteArray(C_ARG_CRIME_ID, crimeId.ToByteArray()); return(new CrimeFragment { Arguments = args }); }
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { var listView = sender as ListView; var bundle = new Bundle(); var serializeDarBytes = _services[e.Position].Serialize(); Debug.Assert(serializeDarBytes != null, nameof(serializeDarBytes) + " != null"); bundle.PutByteArray("SELECTED_ITEM", serializeDarBytes); bundle.PutByteArray("SELECTED_ITEM_IMAGE", _services[e.Position].ImageBytes); var fragment = new ServiceItemFragment { Arguments = bundle }; new FragmentUtil(this.Activity, this.Activity.SupportFragmentManager) .CreateLoadView(Resource.Id.fragment_main_container, fragment); }
private void BackToMain(object sender, EventArgs e) { Intent.Extras.Remove("color"); Bundle bun = new Bundle(); bun.PutByteArray("newColor", new byte[] { color.R, color.G, color.B }); var intent = new Intent(this, typeof(MainActivity)); intent.PutExtra("newColor", bun); StartActivity(intent); }
protected virtual void PreserveViewModel([NotNull] IViewModel viewModel, [NotNull] Bundle bundle) { var state = Get <IViewModelProvider>().PreserveViewModel(viewModel, MugenMvvmToolkit.Models.DataContext.Empty); if (state.Count == 0) { bundle.Remove(StateKey); } else { using (var stream = Get <ISerializer>().Serialize(state)) bundle.PutByteArray(StateKey, stream.ToArray()); } }
//Image an die ImageView Activity übergeben und anzeigen public void showImage(byte[] byteImg) { var intent = new Intent(this, typeof(ImgPreview)); //Bundle erzeugen und ByteArray speichern Bundle b = new Bundle(); b.PutByteArray("img", byteImg); //Bundle zu Intent hinzufügen intent.PutExtra("img", b); //Activity starten StartActivity(intent); }
protected virtual void PreserveState(Bundle bundle, IViewModel viewModel) { if (viewModel == null || bundle == null) { return; } var state = Get <IViewModelProvider>().PreserveViewModel(viewModel, Models.DataContext.Empty); if (state.Count == 0) { bundle.Remove(StateKey); } else { using (var stream = Get <ISerializer>().Serialize(state)) bundle.PutByteArray(StateKey, stream.ToArray()); } }
/// <inheritdoc /> public bool SetByteArray(byte[]?value, [CallerMemberName] string?key = null) { if (key == null) { throw new ArgumentNullException(nameof(key)); } var existingValue = GetByteArray(key: key); if (!ReferenceEquals(existingValue, value) || !ContainsKey(key)) { _bundle.PutByteArray(key, value); OnPropertyChanged(key); return(true); } return(false); }
public bool SetByteArray(byte[]?value, string?key = null) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(key)); } var existingValue = GetByteArray(key: key); if (!ReferenceEquals(existingValue, value) || !ContainsKey(key)) { _bundle.PutByteArray(key, value); OnPropertyChanged(key); return(true); } return(false); }
public static void SaveToBundle(this IStateBundle state, Bundle bundle) { var formatter = new BinaryFormatter(); foreach (var kv in state.Data.Where(x => x.Value != null)) { var value = kv.Value; if (value.GetType().IsSerializable) { using (var stream = new MemoryStream()) { formatter.Serialize(stream, value); stream.Position = 0; bundle.PutByteArray(kv.Key, stream.ToArray()); } } } }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public bool OnNavigationItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.navigation_home: this.OnStop(); return(true); case Resource.Id.navigation_dashboard: var activity = new Intent(this, typeof(CoordonnéeActivity)); Bundle bundle = new Bundle(); bundle.PutByteArray("Data", Coordonnées_Data.ToByte()); activity.PutExtra("Data", bundle); StartActivity(activity); return(true); case Resource.Id.navigation_notifications: ResetHistorique(); return(true); } return(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Activity_url_launcher); var experienceBytes = Intent.GetByteArrayExtra(SimpleArFragment.IntentExtrasKeyExperienceData); var experience = ArExperience.Deserialize(experienceBytes); fragment = (experience.FeaturesMask & Features.Geo) == Features.Geo ? new SimpleGeoFragment() : new SimpleArFragment(); var args = new Bundle(); args.PutByteArray(SimpleArFragment.IntentExtrasKeyExperienceData, experienceBytes); fragment.Arguments = args; var fragmentTransaction = SupportFragmentManager.BeginTransaction(); fragmentTransaction.Replace(Resource.Id.mainFragement, fragment); fragmentTransaction.Commit(); // Prevent device from sleeping Window.AddFlags(flags: WindowManagerFlags.KeepScreenOn); }
protected override void OnCreate(Bundle bundle) { sInstance = this; base.OnCreate(bundle); #if MONOGAME_3_4 || MONOGAME_3_5 _game = new Game1(); SetContentView((View)_game.Services.GetService(typeof(View))); #else Game1.Activity = this; _game = new Game1(); SetContentView(_game.Window); #endif _ouyaInputView = new TV.Ouya.Sdk.OuyaInputView(this); View content = FindViewById(Android.Resource.Id.Content); if (null != content) { content.KeepScreenOn = true; } _game.Run(); Bundle developerInfo = new Bundle(); developerInfo.PutString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID); byte[] applicationKey = null; // load the application key from assets try { AssetManager assetManager = ApplicationContext.Assets; AssetFileDescriptor afd = assetManager.OpenFd(SIGNING_KEY); int size = 0; if (null != afd) { size = (int)afd.Length; afd.Close(); using (Stream inputStream = assetManager.Open(SIGNING_KEY, Access.Buffer)) { applicationKey = new byte[size]; inputStream.Read(applicationKey, 0, size); inputStream.Close(); } } } catch (Exception e) { Log.Error(TAG, string.Format("Failed to read application key exception={0}", e)); } if (null != applicationKey) { Log.Debug(TAG, "Read signing key"); developerInfo.PutByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, applicationKey); } else { Log.Error(TAG, "Failed to authorize with signing key"); Finish(); return; } //developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_ID, "0000000000000"); //developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_KEY, "000000000000000000"); //developerInfo.PutStringArray(OuyaFacade.OUYA_PRODUCT_ID_LIST, Game1.PURCHASABLES); _ouyaFacade = OuyaFacade.Instance; _ouyaFacade.Init(this, developerInfo); }
protected static Bitmap bmp; //in memory storage for user's profile picture protected async override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); base.SetContentView(Resource.Layout.BaseLayout); TextView tvw = FindViewById <TextView>(Resource.Id.tvwWelcome); tvw.Text = "Welcome " + new AppPreferences().GetValue(User.Name); ImageView ProfileImage = FindViewById <ImageView>(Resource.Id.profileImage); ProfileImage.Click += (sender, e) => { FragmentTransaction ft = FragmentManager.BeginTransaction(); MyDialogFragment newFragment = new MyDialogFragment(this); // Pass it with the Bundle class Bundle bundle = new Bundle(); using (MemoryStream stream = new MemoryStream()) { bmp?.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] picByte = stream.ToArray(); bundle.PutByteArray("imgId", picByte); } newFragment.Arguments = bundle; newFragment.Show(ft, "dialog"); //show the Fragment newFragment.imageChanged += async(s, bmpEv) => { //convert bitmap to stream and send using (MemoryStream stream = new MemoryStream()) { bmpEv.Compress(Bitmap.CompressFormat.Jpeg, 100, stream); byte[] imageByte = stream.ToArray(); try { string uri = Values.ApiRootAddress + "UserProfile/PutImage?empNo=" + new AppPreferences().GetValue(User.EmployeeNo) + "&empName=" + new AppPreferences().GetValue(User.UserId) + "&compId=" + new AppPreferences().GetValue(User.CompId); Toast.MakeText(this, Values.WaitingMsg, ToastLength.Short).Show(); dynamic json = await new DataApi().PutAsync(uri, new ByteArrayContent(imageByte)); bool success = DataApi.IsJsonObject(json); if (success) { if (json["ErrorStatus"] == 0) { bmp = bmpEv; ProfileImage.SetImageBitmap(bmp); Toast.MakeText(this, "Uploaded successfully", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Upload failed", ToastLength.Short).Show(); } } else { Toast.MakeText(this, (string)json, ToastLength.Short).Show(); } } catch (Exception ex) { ex.Log(); Toast.MakeText(this, "An error occured while uploading picture", ToastLength.Short).Show(); } } }; }; if (bmp == null) { byte[] picByte = await GenerateProfilePic(); bmp = BitmapFactory.DecodeByteArray(picByte, 0, picByte.Length); ProfileImage.SetImageBitmap(bmp); //if the asynchronous call completes late } else { ProfileImage.SetImageBitmap(bmp); } } catch (Exception ex) { ex.Log(); } }
public static void putByteArray(this Bundle bundle, string key, byte[] value) { bundle.PutByteArray(key, value); }
/** Called when the activity is first created. */ protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); if (APP_ID == null) { Util.ShowAlert (this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see Example.java"); } SetContentView (Resource.Layout.main); mLoginButton = (LoginButton)FindViewById (Resource.Id.login); mText = (TextView)FindViewById (Resource.Id.txt); mRequestButton = (Button)FindViewById (Resource.Id.requestButton); mPostButton = (Button)FindViewById (Resource.Id.postButton); mDeleteButton = (Button)FindViewById (Resource.Id.deletePostButton); mUploadButton = (Button)FindViewById (Resource.Id.uploadButton); mFacebook = new Facebook (APP_ID); mAsyncRunner = new AsyncFacebookRunner (mFacebook); SessionStore.Restore (mFacebook, this); SessionEvents.AddAuthListener (new SampleAuthListener (this)); SessionEvents.AddLogoutListener (new SampleLogoutListener (this)); mLoginButton.Init (this, mFacebook); mRequestButton.Click += delegate { mAsyncRunner.Request ("me", new SampleRequestListener (this)); }; mRequestButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; mUploadButton.Click += async delegate { Bundle parameters = new Bundle (); parameters.PutString ("method", "photos.upload"); URL uploadFileUrl = null; try { uploadFileUrl = new URL ( "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); } catch (MalformedURLException e) { e.PrintStackTrace (); } try { HttpURLConnection conn = (HttpURLConnection)uploadFileUrl.OpenConnection (); conn.DoInput = true; await conn.ConnectAsync (); int length = conn.ContentLength; byte[] imgData = new byte[length]; var ins = conn.InputStream; await ins.ReadAsync (imgData, 0, imgData.Length); parameters.PutByteArray ("picture", imgData); } catch (IOException e) { e.PrintStackTrace (); } mAsyncRunner.Request (null, parameters, "POST", new SampleUploadListener (this), null); }; mUploadButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; mPostButton.Click += delegate { mFacebook.Dialog (this, "feed", new SampleDialogListener (this)); }; mPostButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); if (savedInstanceState != null) { isStarted = savedInstanceState.GetBoolean(SERVICE_STARTED_KEY, false); } serviceToStart = new Intent(this, typeof(WorkService)); stopServiceButton = FindViewById <Button>(Resource.Id.stop_timestamp_service_button); startServiceButton = FindViewById <Button>(Resource.Id.start_timestamp_service_button); if (isStarted) { stopServiceButton.Click += StopServiceButton_Click; stopServiceButton.Enabled = true; startServiceButton.Enabled = false; } else { startServiceButton.Click += StartServiceButton_Click; startServiceButton.Enabled = true; stopServiceButton.Enabled = false; } var listView1 = FindViewById <ListView>(Resource.Id.listView1); listView1.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { var dt = listView1.GetItemAtPosition(e.Position).ToString().Split("|"); Printer.Name = dt[0].Trim(); Printer.Mac = dt[1].Trim(); if (null == WorkService.workThread) { StartService(new Intent(this, typeof(WorkService))); } if (!WorkService.workThread.IsConnected()) { WorkService.workThread.ConnectBt(Printer.Mac); //Sleep for 3 seconds try { Java.Lang.Thread.Sleep(3000); } catch (Exception) { } } if (WorkService.workThread.IsConnected()) { int nTextAlign = 1; String text = "Test message!\r\n\r\n\r\n"; String encoding = "UTF-8"; byte[] hdrBytes = { 0x1c, 0x26, 0x1b, 0x39, 0x01 }; Bundle dataAlign = new Bundle(); Bundle dataTextOut = new Bundle(); Bundle dataHdr = new Bundle(); dataHdr.PutByteArray(Global.BYTESPARA1, hdrBytes); dataHdr.PutInt(Global.INTPARA1, 0); dataHdr.PutInt(Global.INTPARA2, hdrBytes.Length); dataAlign.PutInt(Global.INTPARA1, nTextAlign); dataTextOut.PutString(Global.STRPARA1, text); dataTextOut.PutString(Global.STRPARA2, encoding); WorkService.workThread.HandleCmd(Global.CMD_POS_WRITE, dataHdr); WorkService.workThread.HandleCmd(Global.CMD_POS_SALIGN, dataAlign); WorkService.workThread.HandleCmd(Global.CMD_POS_STEXTOUT, dataTextOut); } else { Toast.MakeText(this, Global.toast_notconnect, ToastLength.Short).Show(); } }; }
protected override void OnSaveInstanceState(Bundle outState) { outState.PutByteArray("configValues", configValues); base.OnSaveInstanceState(outState); }
protected override void OnCreate(Bundle bundle) { sInstance = this; base.OnCreate(bundle); Game1.Activity = this; mGame = new Game1(); SetContentView(mGame.Window); using (var ignore = new TV.Ouya.Sdk.OuyaInputView(this)) { // do nothing } View content = FindViewById (Android.Resource.Id.Content); if (null != content) { content.KeepScreenOn = true; } mGame.Run(); Bundle developerInfo = new Bundle(); developerInfo.PutString(OuyaFacade.OUYA_DEVELOPER_ID, "310a8f51-4d6e-4ae5-bda0-b93878e5f5d0"); byte[] applicationKey = null; // load the application key from assets try { AssetManager assetManager = ApplicationContext.Assets; AssetFileDescriptor afd = assetManager.OpenFd(SIGNING_KEY); int size = 0; if (null != afd) { size = (int)afd.Length; afd.Close(); using (Stream inputStream = assetManager.Open(SIGNING_KEY, Access.Buffer)) { applicationKey = new byte[size]; inputStream.Read(applicationKey, 0, size); inputStream.Close(); } } } catch (Exception e) { Log.Error (TAG, string.Format("Failed to read application key exception={0}", e)); } if (null != applicationKey) { Log.Debug (TAG, "Read signing key"); developerInfo.PutByteArray (OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, applicationKey); } else { Log.Error (TAG, "Failed to authorize with signing key"); Finish (); return; } developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_ID, "0000000000000"); developerInfo.PutString(OuyaFacade.XIAOMI_APPLICATION_KEY, "000000000000000000"); developerInfo.PutStringArray(OuyaFacade.OUYA_PRODUCT_ID_LIST, Game1.PURCHASABLES); _ouyaFacade = OuyaFacade.Instance; _ouyaFacade.Init(this, developerInfo); }
/** Called when the activity is first created. */ protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (APP_ID == null) { Util.ShowAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see Example.java"); } SetContentView(Resource.Layout.main); mLoginButton = (LoginButton)FindViewById(Resource.Id.login); mText = (TextView)FindViewById(Resource.Id.txt); mRequestButton = (Button)FindViewById(Resource.Id.requestButton); mPostButton = (Button)FindViewById(Resource.Id.postButton); mDeleteButton = (Button)FindViewById(Resource.Id.deletePostButton); mUploadButton = (Button)FindViewById(Resource.Id.uploadButton); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); SessionStore.Restore(mFacebook, this); SessionEvents.AddAuthListener(new SampleAuthListener(this)); SessionEvents.AddLogoutListener(new SampleLogoutListener(this)); mLoginButton.Init(this, mFacebook); mRequestButton.Click += delegate { mAsyncRunner.Request("me", new SampleRequestListener(this)); }; mRequestButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; mUploadButton.Click += async delegate { Bundle parameters = new Bundle(); parameters.PutString("method", "photos.upload"); URL uploadFileUrl = null; try { uploadFileUrl = new URL( "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg"); } catch (MalformedURLException e) { e.PrintStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection)uploadFileUrl.OpenConnection(); conn.DoInput = true; await conn.ConnectAsync(); int length = conn.ContentLength; byte[] imgData = new byte[length]; var ins = conn.InputStream; await ins.ReadAsync(imgData, 0, imgData.Length); parameters.PutByteArray("picture", imgData); } catch (IOException e) { e.PrintStackTrace(); } mAsyncRunner.Request(null, parameters, "POST", new SampleUploadListener(this), null); }; mUploadButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; mPostButton.Click += delegate { mFacebook.Dialog(this, "feed", new SampleDialogListener(this)); }; mPostButton.Visibility = mFacebook.IsSessionValid ? ViewStates.Visible : ViewStates.Invisible; }