protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it editText = FindViewById<EditText> (Resource.Id.editText1); button = FindViewById<Button> (Resource.Id.unlockButton); masterCodeText = FindViewById<TextView>(Resource.Id.masterCodeText); serviceCodeText = FindViewById<TextView>(Resource.Id.serviceCodeText); button.Click += delegate { string masterCode; string serviceCode; ulong userCode; if (ulong.TryParse(editText.Text, out userCode)) { ThreeDSUnlockLib.Unlocker.GetUnlockKey(userCode, out masterCode, out serviceCode); masterCodeText.Text = masterCode; serviceCodeText.Text = serviceCode; } }; if (bundle != null) { editText.Text = bundle.GetString ("editText"); masterCodeText.Text = bundle.GetString ("masterCodeText"); serviceCodeText.Text = bundle.GetString ("serviceCodeText"); } }
public override void Handle(Bundle bundle) { //�������������������֪ͨ�ı��⡣ //��Ӧ API ֪ͨ���ݵ� title �ֶΡ� //��Ӧ Portal ����֪ͨ�����ϵġ�֪ͨ���⡱�ֶΡ� var title = bundle.GetString(JPushInterface.ExtraNotificationTitle); //�������������������֪ͨ���ݡ� //��Ӧ API ֪ͨ���ݵ� alert �ֶΡ� //��Ӧ Portal ����֪ͨ�����ϵġ�֪ͨ���ݡ��ֶΡ� var ctx = bundle.GetString(JPushInterface.ExtraAlert); //SDK 1.2.9 ���ϰ汾֧�֡� //������������������ĸ����ֶΡ����Ǹ� JSON �ַ����� //��Ӧ API ֪ͨ���ݵ� extras �ֶΡ� //��Ӧ Portal ������Ϣ�����ϵġ���ѡ���á���ĸ����ֶΡ� var extra = bundle.GetString(JPushInterface.ExtraExtra); //SDK 1.3.5 ���ϰ汾֧�֡� //֪ͨ����Notification ID�������������Notification var id = bundle.GetString(JPushInterface.ExtraNotificationId); //SDK 1.6.1 ���ϰ汾֧�֡� //Ψһ��ʶ֪ͨ��Ϣ�� ID, �������ϱ�ͳ�Ƶȡ� var msgID = bundle.GetString(JPushInterface.ExtraMsgId); }
private void SendNotification (Bundle data) { Intent intent; string type = data.GetString("type"); intent = new Intent (this, typeof(MainActivity)); if(type.Equals(PUSH_INVITE)) { ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId")); intent.SetAction(PUSH_INVITE); } else if(type.Equals(PUSH_EVENT_UPDATE)) { ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId")); intent.SetAction(PUSH_EVENT_UPDATE); } else if(type.Equals(PUSH_DELETE)) { //nothing else need to be done //MainActivity will refresh the events on start } intent.AddFlags (ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot); var notificationBuilder = new Notification.Builder(this) .SetSmallIcon (Resource.Drawable.pushnotification_icon) .SetContentTitle (data.GetString("title")) .SetContentText (data.GetString ("message")) .SetVibrate(new long[] {600, 600}) .SetAutoCancel (true) .SetContentIntent (pendingIntent); var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); notificationManager.Notify (notificationId, notificationBuilder.Build()); notificationId++; }
public string GetProtocolKeyFromHandShakeResult(Bundle bundleResult) { var negotiatedBrokerProtocalKey = bundleResult?.GetString(BrokerConstants.NegotiatedBPVersionKey); if (!string.IsNullOrEmpty(negotiatedBrokerProtocalKey)) { _logger.Info("[Android broker] Using broker protocol version: " + negotiatedBrokerProtocalKey); return(negotiatedBrokerProtocalKey); } dynamic errorResult = JObject.Parse(bundleResult?.GetString(BrokerConstants.BrokerResultV2)); string errorCode = null; string errorDescription = null; if (!string.IsNullOrEmpty(errorResult)) { errorCode = errorResult[BrokerResponseConst.BrokerErrorCode]?.ToString(); string errorMessage = errorResult[BrokerResponseConst.BrokerErrorMessage]?.ToString(); errorDescription = $"[Android broker] An error occurred during hand shake with the broker. Error: {errorCode} Error Message: {errorMessage}"; } else { errorCode = BrokerConstants.BrokerUnknownErrorCode; errorDescription = "[Android broker] An error occurred during hand shake with the broker, no detailed error information was returned. "; } _logger.Error(errorDescription); throw new MsalClientException(errorCode, errorDescription); }
protected override void OnRestoreInstanceState(Bundle savedInstanceState) { this.topicName = savedInstanceState.GetString("topicName"); this.topicArn = savedInstanceState.GetString("topicArn"); this.createTopic.Enabled = topicName == null; this.subscribe.Enabled = topicName != null; this.deleteTopic.Enabled = topicName != null; }
public override void OnMessageReceived (string from, Bundle data) { var message = data.GetString ("message"); var type = data.GetString("type"); Log.Info ("MyGcmListenerService", "From: " + from); Log.Info ("MyGcmListenerService", "Message: " + message); Log.Info ("MyGcmListenerService", "Type: " + type); if(!type.Equals(PUSH_REGISTRATION_VALIDATION)) SendNotification (data); }
public Server(Bundle b) : this(b.GetInt("SERVER_ID"), b.GetString("SERVER_NAME"), b.GetString("SERVER_SCHEME"), b.GetString("SERVER_HOSTNAME"), b.GetInt("SERVER_PORT"), b.GetString("SERVER_USER"), b.GetString("SERVER_PASS"), b.GetInt("SERVER_GID")) { }
public override void OnMessageReceived(string from, Bundle data) { MessaggioNotifica m = new MessaggioNotifica (); string messaggio = data.GetString ("messaggio"); string titolo = data.GetString ("titolo"); string commessa = data.GetString ("commessa"); string tipo = data.GetString ("tipo"); m.Titolo = titolo; m.Messaggio = messaggio; m.Commessa = commessa; m.Tipo = tipo; Log.Debug ("MyGcmListenerService", "Message: " + messaggio); SendNotification (m); }
protected virtual IEnumerable <string> GetIncludedCategories() { string include = arguments?.GetString("include"); if (!string.IsNullOrEmpty(include)) { foreach (var category in include.Split(':')) { yield return(category); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.WikiNoteEditor); _noteEdit = (EditText)FindViewById(Resource.Id.noteEdit); string wikiNoteText = bundle == null ? null : bundle.GetString(WikiNote.Notes.BODY); string wikiNoteTitle = bundle == null ? null : bundle.GetString(WikiNote.Notes.TITLE); if (wikiNoteTitle == null) { Bundle extras = Intent.Extras; wikiNoteText = extras == null ? null : extras.GetString(WikiNote.Notes.BODY); wikiNoteTitle = extras == null ? null : extras.GetString(WikiNote.Notes.TITLE); } // If we have no title information, this is an invalid intent request if (TextUtils.IsEmpty(wikiNoteTitle)) { // no note title - bail SetResult(Result.Canceled); Finish(); return; } _wikiNoteTitle = wikiNoteTitle; // set the title so we know which note we are editing Title = GetString(Resource.String.wiki_editing, wikiNoteTitle); // but if the body is null, just set it to empty - first edit of this note wikiNoteText = wikiNoteText == null ? "" : wikiNoteText; // set the note body to edit _noteEdit.Text = wikiNoteText; // set listeners for the confirm and cancel buttons ((Button)FindViewById(Resource.Id.confirmButton)) .Click += delegate { Intent i = new Intent(); i.PutExtra(ACTIVITY_RESULT, _noteEdit.Text); SetResult(Result.Ok, i); Finish(); }; ((Button)FindViewById(Resource.Id.confirmButton)) .Click += delegate { SetResult(Result.Canceled); Finish(); }; }
public override async void OnMessageReceived(string from, Bundle data) { if (!ServiceFinder.IsRegistered<IPush>()) { await FHClient.Init(); FH.RegisterPush(DefaultHandleEvent); } var push = ServiceFinder.Resolve<IPush>() as Push; var message = data.GetString("alert"); var messageData = data.KeySet().ToDictionary(key => key, key => data.GetString(key)); (push.Registration as GcmRegistration).OnPushNotification(message, messageData); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); userName = bundle.GetString ("Username"); password = bundle.GetString ("Password"); SetContentView (Resource.Layout.SignupPage); informativeText = FindViewById<TextView> (Resource.Id.InformativeText); actionButton = FindViewById<Button> (Resource.Id.ActionButton); secondActionButton = FindViewById<Button> (Resource.Id.ActionSecondButton); progress = FindViewById<ProgressBar> (Resource.Id.Spinner); actionButton.Click += CancelAction; }
/// <summary> /// This method gets called when a message is received by the listener /// </summary> /// <param name="from">The user who send the message</param> /// <param name="data">The data of the message, includes the message text and message code</param> public override void OnMessageReceived(string from, Bundle data) { var message = data.GetString("message"); int ms_code = 0; int.TryParse((data.GetString ("message_code")), out ms_code); string username = data.GetString ("username_from"); //Create a new message object to be stored MeetMeet_Native_Portable.Droid.Message m = new MeetMeet_Native_Portable.Droid.Message (); m.MsgText = message; m.Date = System.DateTime.Now.ToString(); m.incoming = true; //Check the message code to decide what to do with the message if(ms_code == 1) { //This is for single messages, simply save the message and display a notification m.UserName = username; MessageRepository.SaveMessage (m); SendNotification(message, username); } else if(ms_code == 2) { //This is for group invites, bring up the invite screen Intent intent = new Intent(this, typeof(InviteRequestActivity)); intent.PutExtra ("username_from", username); intent.SetFlags (ActivityFlags.NewTask); StartActivity(intent); } else if(ms_code == 3){ //This is for group messages, save the message to the group conversation and add the sending user's name //to the message text. Then display a notification m.UserName = "******"; m.MsgText = username + ": " + m.MsgText; MessageRepository.SaveMessage (m); SendNotification(message, m.UserName); } //Try to add it to the inbox, if the inbox has been created. //Otherwise, it will get added automatically when the user opens the inbox ViewInbox inbox = (ViewInbox)MainActivity.references.Get ("Inbox"); if(inbox != null) { inbox.newMessage (m); } }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView(Resource.Layout.fragment_tabs); tabHost = FindViewById<TabHost>(Android.Resource.Id.TabHost); tabHost.Setup(); tabManager = new TabManager(this, tabHost, Resource.Id.realtabcontent); tabManager.AddTab(tabHost.NewTabSpec("simple").SetIndicator("Simple"), Java.Lang.Class.FromType(typeof(FragmentStackSupport.CountingFragment)), null); tabManager.AddTab(tabHost.NewTabSpec("contacts").SetIndicator("Custom"), Java.Lang.Class.FromType(typeof(LoaderCursorSupport.CursorLoaderListFragment)), null); /*tabManager.AddTab(tabHost.NewTabSpec("contacts").SetIndicator("Contacts"), LoaderCursorSupport.CursorLoaderListFragment.class, null); tabManager.AddTab(tabHost.NewTabSpec("custom").SetIndicator("Custom"), LoaderCustomSupport.AppListFragment.class, null); tabManager.AddTab(mttabHost.NewTabSpec("throttle").SetIndicator("Throttle"), LoaderThrottleSupport.ThrottledLoaderListFragment.class, null); */ if (savedInstanceState != null) { tabHost.SetCurrentTabByTag(savedInstanceState.GetString("tab")); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment view = inflater.Inflate (Resource.Layout.fragment_exhibitpage_timeslider, container, false); sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(Activity); if (savedInstanceState?.GetString (INSTANCE_STATE_PAGE) != null) { var pageId = savedInstanceState.GetString (INSTANCE_STATE_PAGE); page = PageManager.GetTimesliderPage (pageId); } SetData (); Init(); if (page.HideYearNumbers) { view.FindViewById(Resource.Id.displayImageSliderSeekBarFirstText).Visibility = ViewStates.Invisible; view.FindViewById(Resource.Id.displayImageSliderSeekBarEndText).Visibility = ViewStates.Invisible; } // for tooltips mSeekBar.ViewTreeObserver.AddOnGlobalLayoutListener(new SeekbarLayoutListener(this, mSeekBar, Activity)); return view; }
public override void OnMessageReceived(string from, Bundle data) { var message = data.GetString ("message"); Log.Debug ("MyGcmListenerService", "From: " + from); Log.Debug ("MyGcmListenerService", "Message: " + message); SendNotification (message); }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.Main); // Create a new taskMaster, or restore a saved one if (savedInstanceState == null) { taskMaster = new TaskMaster ("testing"); } else { // Deserialized the saved object state string xmlTasks = savedInstanceState.GetString("Tasks"); XmlSerializer x = new XmlSerializer(typeof(TaskMaster)); taskMaster = (TaskMaster)x.Deserialize(new StringReader(xmlTasks)); } // Display all the tasks var taskTextView = FindViewById<TextView> (Resource.Id.taskTextView); taskTextView.Text = taskMaster.GetTaskDescriptions (); // Add a new task to the taskMaster list Button enterButton = FindViewById<Button> (Resource.Id.enterButton); var taskEditText = FindViewById<EditText>(Resource.Id.taskEditText); enterButton.Click += delegate { taskMaster.AddTask(taskEditText.Text); taskTextView.Text = taskMaster.GetTaskDescriptions (); taskEditText.Text = ""; }; }
protected void OnCreate(Bundle bundle) { if (_id == Guid.Empty) { _id = Guid.NewGuid(); } var oldId = bundle?.GetString(IdKey); if (string.IsNullOrEmpty(oldId)) { return; } var cacheDataContext = GetFromCache(Guid.Parse(oldId)); var vmTypeName = bundle.GetString(ViewModelTypeNameKey); if (vmTypeName == null) { return; } bundle.Remove(ViewModelTypeNameKey); var vmType = Type.GetType(vmTypeName, false); if (vmType != null && (cacheDataContext == null || !cacheDataContext.GetType().Equals(vmType))) { if (!bundle.ContainsKey(IgnoreStateKey)) { cacheDataContext = RestoreViewModel(vmType, bundle); } } if (!ReferenceEquals(DataContext, cacheDataContext)) { RestoreContext(Target, cacheDataContext); } }
public Loader OnCreateLoader (int loaderIndex, Bundle args) { // Where the Contactables table excels is matching text queries, // not just data dumps from Contacts db. One search term is used to query // display name, email address and phone number. In this case, the query was extracted // from an incoming intent in the handleIntent() method, via the // intent.getStringExtra() method. String query = args.GetString (QUERY_KEY); var uri = Android.Net.Uri.WithAppendedPath (ContactsContract.CommonDataKinds.Contactables.ContentFilterUri, query); // Easy way to limit the query to contacts with phone numbers. String selection = ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.HasPhoneNumber + " = " + 1; // Sort results such that rows for the same contact stay together. String sortBy = ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.LookupKey; return new CursorLoader ( mContext, // Context uri, // URI representing the table/resource to be queried null, // projection - the list of columns to return. Null means "all" selection, // selection - Which rows to return (condition rows must match) null, // selection args - can be provided separately and subbed into selection. sortBy); // string specifying sort order }
public static async Task <Bundle> RunTestsAsync(ITestEntryPoint testEntryPoint, Bundle arguments = null) { var resultsFileName = arguments?.GetString("results-file-name", DefaultTestResultsFilename) ?? DefaultTestResultsFilename; var bundle = new Bundle(); var entryPoint = new TestEntryPoint(testEntryPoint, resultsFileName); entryPoint.TestsCompleted += (sender, results) => { var message = $"Tests run: {results.ExecutedTests} " + $"Passed: {results.PassedTests} " + $"Inconclusive: {results.InconclusiveTests} " + $"Failed: {results.FailedTests} " + $"Ignored: {results.SkippedTests}"; bundle.PutString("test-execution-summary", message); bundle.PutLong("return-code", results.FailedTests == 0 ? 0 : 1); }; await entryPoint.RunAsync(); if (File.Exists(entryPoint.TestsResultsFinalPath)) { bundle.PutString("test-results-path", entryPoint.TestsResultsFinalPath); } if (bundle.GetLong("return-code", -1) == -1) { bundle.PutLong("return-code", 1); } return(bundle); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment var v = inflater.Inflate(Resource.Layout.fragment_exhibitpage_image, container, false); if (savedInstanceState?.GetString(INSTANCE_STATE_PAGE) != null) { var pageId = savedInstanceState.GetString(INSTANCE_STATE_PAGE); page = PageManager.GetImagePage(pageId); } drawView = (DrawView)v.FindViewById(Resource.Id.fragment_exhibitpage_image_imageview); drawView.SetImageDrawable(page.Image.GetDrawable(Context, drawView.Width, drawView.Height)); if (page.Areas != null && page.Areas.Count > 0) { drawView.Rectangles.AddRange(page.Areas); } else { //There are no areas to highlight, don't show button var button = (Button)v.FindViewById(Resource.Id.fragment_exhibitpage_image_button); button.Visibility = ViewStates.Invisible; } drawView.OriginalImageDimensions = new [] { page.Image.Width, page.Image.Height }; InitListeners(v); return(v); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KeyContent)) _content = savedInstanceState.GetString(KeyContent); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { _myShow = new TVShow(); _myShow = JsonConvert.DeserializeObject<TVShow>(savedInstanceState.GetString("showSerialized")); } // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); var view = inflater.Inflate(Resource.Layout.show_description_fragment, container, false); var backgroundLinearLayout = view.FindViewById<LinearLayout>(Resource.Id.linLayout); //backgroundLinearLayout.SetBackgroundColor(Color.Red); //Koush.UrlImageViewHelper.SetUrlDrawable(backgroundLinearLayout, // "http://image.tmdb.org/t/p/w92" + _myShow.Seasons[position].PosterPath); var showTitle = view.FindViewById<TextView>(Resource.Id.showTitle); showTitle.Text = _myShow.Name + " with " + _myShow.Actors.Count + " in the cast and the Overview:"+ _myShow.Overview; return view; }
protected override void OnCreate(Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(bundle); SetContentView(Resource.Layout.Viewer); // associate the views MainImage = FindViewById<ZoomImageView>(Resource.Id.MainImage); Zoom = FindViewById<ZoomControls>(Resource.Id.ZoomButtons); OpenButton = FindViewById<ImageButton>(Resource.Id.OpenButton); LeftButton = FindViewById<ImageButton>(Resource.Id.LeftButton); RightButton = FindViewById<ImageButton>(Resource.Id.RightButton); // wire the views Zoom.ZoomInClick += (src, args) => MainImage.ZoomIn(); Zoom.ZoomOutClick += (src, args) => MainImage.ZoomOut(); OpenButton.Click += (src, args) => OnOpenButtonClick(args); LeftButton.Click += (src, args) => OnLeftButtonClick(args); RightButton.Click += (src, args) => OnRightButtonClick(args); // get preferences var prefs = GetSharedPreferences("Global", FileCreationMode.Private); // check bundles and prefs if (Intent.Extras != null && Intent.Extras.ContainsKey("ComicsPath")) Controller = new ViewerController(this, Intent.Extras.GetString("ComicsPath")); else if (bundle != null && bundle.ContainsKey("ComicsPath")) Controller = new ViewerController(this, bundle.GetString("ComicsPath")); else Controller = new ViewerController(this, prefs.GetString("ComicsPath", null)); }
public static AppTask CreateFromBundle(Bundle b, AppTask failureReturn) { if (b == null) return failureReturn; string taskType = b.GetString(AppTaskKey); if (string.IsNullOrEmpty(taskType)) return failureReturn; try { Type type = Type.GetType("keepass2android." + taskType); if (type == null) return failureReturn; AppTask task = (AppTask)Activator.CreateInstance(type); task.Setup(b); return task; } catch (Exception e) { Kp2aLog.Log("Cannot convert " + taskType + " in task: " + e); return failureReturn; } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); currentBaseUrl = "file://android_asset/"; currentUrl = "file:///android_asset/index.html"; if (bundle != null) { if (bundle.ContainsKey(UrlKey)) currentUrl = bundle.GetString(UrlKey); if (bundle.ContainsKey(ConfigKey)) inputConfiguration = JsonSerializer.Deserialize<InputConfiguration>(bundle.GetString(ConfigKey)); } CheckFirstRun(); LoadUrl(); }
protected override void OnRestoreInstanceState(Bundle savedInstanceState) { this.bucketName = savedInstanceState.GetString("bucketName"); this.createButton.Enabled = bucketName == null; this.uploadButton.Enabled = bucketName != null; this.deleteButton.Enabled = bucketName != null; }
private void UpdateItemsFromBundle(Bundle savedInstanceState) { if (!string.IsNullOrEmpty(savedInstanceState?.GetString(nameof(_items)))) { string _serializedItems = savedInstanceState.GetString(nameof(_items)); _items = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(_serializedItems); } }
public static void EnsureInitialized(object sender = null, Bundle bundle = null, Func <AndroidBootstrapperBase> factory = null) { if (factory == null) { factory = BootstrapperFactory; } if (Current == null) { lock (Locker) { if (Current == null) { if (factory == null) { Type type; var typeString = bundle?.GetString(BootTypeKey); if (string.IsNullOrEmpty(typeString)) { BootstrapperAttribute bootstrapperAttribute = null; if (sender != null) { bootstrapperAttribute = sender.GetType().Assembly.GetCustomAttribute <BootstrapperAttribute>(); } if (bootstrapperAttribute == null) { foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { bootstrapperAttribute = (BootstrapperAttribute)assembly .GetCustomAttributes(typeof(BootstrapperAttribute), false) .FirstOrDefault(); if (bootstrapperAttribute != null) { break; } } if (bootstrapperAttribute == null) { throw new InvalidOperationException(@"The BootstrapperAttribute was not found. You must specify the type of application bootstrapper using BootstrapperAttribute, for example [assembly:Bootstrapper(typeof(MyBootstrapperType))]"); } } type = bootstrapperAttribute.BootstrapperType; } else { type = Type.GetType(typeString, true); } Current = (AndroidBootstrapperBase)Activator.CreateInstance(type); } else { Current = factory(); } } } } Current.Initialize(); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your fragment here if (savedInstanceState != null) { this._userInputText = savedInstanceState.GetString(UserInput); } }
//@Override public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if ((savedInstanceState != null) && savedInstanceState.ContainsKey(KEY_CONTENT)) { mContent = savedInstanceState.GetString(KEY_CONTENT); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); PrepareActionBar(); var id = Intent.Extras.GetInt(KEY_ID); if (savedInstanceState == null) { var newsService = new NewsService(); _news = newsService.GetNewsById(id); } else { _news = new News(); _news.Id = savedInstanceState.GetInt(KEY_ID); _news.Body = savedInstanceState.GetString(KEY_BODY); _news.ImageName = savedInstanceState.GetString(KEY_IMAGE_NAME); _news.Title = savedInstanceState.GetString(KEY_TITLE); } var newsTitle = FindViewById <TextView>(Resource.Id.newsTitle); var newsBody = FindViewById <TextView>(Resource.Id.newsBody); var newsImage = FindViewById <ImageView>(Resource.Id.newsImage); var display = WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); var imageURL = string.Concat(ValuesService.ImagesBaseURL, _news.ImageName); Picasso.With(ApplicationContext) .Load(imageURL) .Resize(point.X, 0) .Into(newsImage); newsTitle.Text = _news.Title; newsBody.Text = _news.Body; }
private AuthenticationResultEx GetResultFromBrokerResponse(Bundle bundleResult) { if (bundleResult == null) { throw new Exception("bundleResult"); } int errCode = bundleResult.GetInt(AccountManager.KeyErrorCode); string msg = bundleResult.GetString(AccountManager.KeyErrorMessage); if (!string.IsNullOrEmpty(msg)) { throw new AdalException(errCode.ToString(), msg); } else { bool initialRequest = bundleResult.ContainsKey(BrokerConstants.AccountInitialRequest); if (initialRequest) { // Initial request from app to Authenticator needs to launch // prompt. null resultEx means initial request return(null); } // IDtoken is not present in the current broker user model UserInfo userinfo = GetUserInfoFromBrokerResult(bundleResult); AuthenticationResult result = new AuthenticationResult("Bearer", bundleResult.GetString(AccountManager.KeyAuthtoken), ConvertFromTimeT(bundleResult.GetLong("account.expiredate", 0))) { UserInfo = userinfo }; result.UpdateTenantAndUserInfo(bundleResult.GetString(BrokerConstants.AccountUserInfoTenantId), null, userinfo); return(new AuthenticationResultEx { Result = result, RefreshToken = null, ResourceInResponse = null, }); } }
/// <summary> /// Receives a Message from GCM. The method exctracts a message from the Bundle data, /// and calls SendNotification. /// /// If the students have enabled receiveNotifications, but /// disabled receiveProjectNotifications and receiveJobNotifications /// The student can still receive more general messages sent as push notifications /// however these notifications will only be displayed once and won't be displayed in the /// notification list. /// </summary> public override async void OnMessageReceived(string from, Bundle data) { DbStudent dbStudent = new DbStudent(); var message = data.GetString("message"); Log.Debug("MyGcmListenerService", "From: " + from); Log.Debug("MyGcmListenerService", "Message: " + message); var type = data.GetString("type"); var uuid = data.GetString("uuid"); Student student = dbStudent.GetStudent(); if (student != null && student.receiveNotifications) { DbNotification dbNotification = new DbNotification(); if (type == "project") { if (student.receiveProjectNotifications) { SendNotification(message); Log.Debug("MyGcmListenerService", "type: " + type); Log.Debug("MyGcmListenerService", "uuid: " + uuid); // type = job or project Log.Debug("MyGcmListenerService", "After New NotificationController, but before use of method."); dbNotification.InsertNotification(type, uuid); } } else if (type == "job") { if (student.receiveJobNotifications) { SendNotification(message); Log.Debug("MyGcmListenerService", "type: " + type); Log.Debug("MyGcmListenerService", "uuid: " + uuid); // type = job or project Log.Debug("MyGcmListenerService", "After New NotificationController, but before use of method."); dbNotification.InsertNotification(type, uuid); } } else { SendNotification(message); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); if (savedInstanceState != null) { // Deserialized the saved object state XmlSerializer x = new XmlSerializer(typeof(QuoteBank)); string xml = savedInstanceState.GetString("Quotes"); quoteCollection = (QuoteBank)x.Deserialize(new StringReader(xml)); } else { // Create the quote collection and display the current quote quoteCollection = new QuoteBank(); quoteCollection.LoadQuotes(); quoteCollection.GetNextQuote(); } quotationTextView = FindViewById <TextView>(Resource.Id.quoteTextView); quotationTextView.Text = quoteCollection.CurrentQuote.Quotation; TextView authorTextView = FindViewById <TextView>(Resource.Id.quoteAuthorTextView); authorTextView.Text = quoteCollection.CurrentQuote.Person; // Display another quote when the "Next Quote" button is tapped var nextButton = FindViewById <Button>(Resource.Id.nextButton); nextButton.Click += delegate { quoteCollection.GetNextQuote(); quotationTextView.Text = quoteCollection.CurrentQuote.Quotation; authorTextView.Text = quoteCollection.CurrentQuote.Person; }; var saveButton = FindViewById <Button>(Resource.Id.saveButton); saveButton.Click += delegate { Quote q = new Quote(); q.Quotation = FindViewById <EditText>(Resource.Id.newQuoteText).Text; q.Person = FindViewById <EditText>(Resource.Id.newQuoteAuthor).Text; quoteCollection.Quotes.Add(q); FindViewById <EditText>(Resource.Id.newQuoteAuthor).Text = ""; FindViewById <EditText>(Resource.Id.newQuoteText).Text = ""; }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ProductDetail); Bundle extras = Intent.Extras; String actionText = extras.GetString(GameStoreConstants.ParamAction); EditText name = (EditText)FindViewById(Resource.Id.productname); EditText price = (EditText)FindViewById(Resource.Id.price); Button loadImage = (Button)FindViewById(Resource.Id.loadimage); ImageView image = (ImageView)FindViewById(Resource.Id.image); switch (actionText) { case GameStoreConstants.ParamActionAdd: mAction = DetailViewMode.Add; break; case GameStoreConstants.ParamActionEdit: mAction = DetailViewMode.Edit; break; default: break; } mProduct = new Product(); if (mAction == DetailViewMode.Edit) { int id = extras.GetInt(GameStoreConstants.ParamId); mProduct = DatabaseHelper.Database.GetProduct(id); if (mProduct != null) { name.Text = mProduct.ProductName; price.Text = Convert.ToString(mProduct.Price); Bitmap bitmap = ImageHelper.BytesToBitmap(mProduct.Image); image.SetImageBitmap(bitmap); Drawable drawable = new BitmapDrawable(Resources, bitmap); loadImage.Background = drawable; loadImage.Text = ""; } } loadImage.Click += delegate { var imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); StartActivityForResult( Intent.CreateChooser(imageIntent, "Select photo"), 0); //Intent intent = new Intent(Intent.ActionPick, MediaStore.Images.Media.ExternalContentUri); //StartActivityForResult(intent, 0); }; }
protected static int GetIntFromBundle(Bundle b, string key, int defaultValue) { int intValue; if (!Int32.TryParse(b.GetString(key), out intValue)) { intValue = defaultValue; } return(intValue); }
public override void OnMessageReceived(string from, Bundle data) { // Extract the message received from GCM: var message = data.GetString("message"); Log.Debug("MyGcmListenerService", "From: " + from); Log.Debug("MyGcmListenerService", "Message: " + message); // Forward the received message in a local notification: SendNotification(message); }
public static Recipe FromBundle(Bundle bundle) { var recipe = new Recipe(); recipe.TitleText = bundle.GetString(Constants.RecipeFieldTitle); recipe.SummaryText = bundle.GetString(Constants.RecipeFieldSummary); recipe.RecipeImage = bundle.GetString(Constants.RecipeFieldImage); recipe.IngredientsText = bundle.GetString(Constants.RecipeFieldIngredients); var stepBundles = bundle.GetParcelableArrayList(Constants.RecipeFieldSteps); if (stepBundles != null) { foreach (IParcelable stepBundle in stepBundles) { recipe.RecipeSteps.Add(RecipeStep.FromBundle((Bundle)stepBundle)); } } return(recipe); }
protected override void InitVariables() { fromIntent = this.Intent; Bundle bundle = fromIntent.Extras; if (bundle != null) { AreaCodes = bundle.GetString("areaCodes", ""); } }
public override void OnCreate(Bundle arguments) { base.OnCreate(arguments); AssetCopier.CopyAssets(); resultsFileName = arguments.GetString("results-file-name", "TestResults.xml"); Start(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Bundle extras = Intent.Extras; _product = JsonConvert.DeserializeObject <SwapProduct>(extras.GetString("product")); _productComponentsResponse = JsonConvert.DeserializeObject <ProductComponentsResponse>(extras.GetString("productComponentsResponse")); _customerDetailsResponse = JsonConvert.DeserializeObject <CustomerDetailsResponse>(extras.GetString("customerDetailsResponse")); InitializeScreen(); }
// Adds an account of the specified accountType. public override Bundle AddAccount(AccountAuthenticatorResponse response, string accountType, string authTokenType, string[] requiredFeatures, Bundle options) { var acc = new Account(options.GetString(AccountManager.KeyAccountName), accountType); var am = AccountManager.Get(this.context); am.AddAccountExplicitly(acc, null, options); return(null); }
private void GetExistingAccountAuthToken(Account account, string tokenType) { var mFuture = mAccountManager.GetAuthToken(account, tokenType, null, null, null, null); var thread = new Thread(() => { Bundle bnd = mFuture.Result as Bundle; string authtoken = bnd.GetString(AccountManager.KeyAuthtoken); }); thread.Start(); }
public override void OnMessageReceived (string from, Bundle data) { // Extract the message received from GCM: var message = data.GetString("message"); Log.Debug("MyGcmListenerService", "From: " + from); Log.Debug("MyGcmListenerService", "Message: " + message); // Forward the received message in a local notification: SendNotification (message); }
public override void OnMediaControllConnected() { if (voiceSearchParams != null) { var query = voiceSearchParams.GetString(Android.App.SearchManager.Query); SupportMediaController.GetTransportControls().PlayFromSearch(query, voiceSearchParams); voiceSearchParams = null; } //TODO: CurrentFragment.OnConnected(); }
private void AddToOutboundQueue(byte[] data, Bundle rinfo) { try { outboundQueue.Enqueue(new DatagramPacket(data, data.Length, InetAddress.GetByName(rinfo.GetString(midi.MIDIConstants.RINFO_ADDR)), rinfo.GetInt(midi.MIDIConstants.RINFO_PORT))); selector.Wakeup(); } catch (UnknownHostException e) { throw new UnknownHostException(e.StackTrace); } }
/// <summary> /// Creates this fragment /// </summary> /// <param name="savedState">The saved state</param> public override void OnCreate(Bundle savedState) { base.OnCreate(savedState); RetainInstance = true; if (savedState != null) { string savedJson = savedState.GetString(BundledRegistrationInfo); this.SetData(savedJson); } }
protected override void OnRestoreInstanceState(Bundle savedInstanceState) { base.OnRestoreInstanceState(savedInstanceState); try { _doNotCancel = savedInstanceState.GetBoolean(DoNotCancelKey, false); if (_previousParents == null || _previousParents.Count == 0) { var src = savedInstanceState.GetString(PreviousParentsKey); if (!string.IsNullOrEmpty(src)) { _previousParents = JsonConvert.DeserializeObject <Stack <string> >(src); } } if (_selectedItem == null) { var src = savedInstanceState.GetString(SelectedItemKey); if (!string.IsNullOrEmpty(src)) { _selectedItem = JsonConvert.DeserializeObject <FileDocumentItem>(src); } } _orderBy = (FileDocumentItemSortOrders)savedInstanceState.GetInt(OrderByKey); if (_currentParent == null) { var src = savedInstanceState.GetString(CurrentParentKey); if (!string.IsNullOrEmpty(src)) { _currentParent = JsonConvert.DeserializeObject <FileDocumentItem>(src); ReplaceFragment(); } } } catch (Exception ex) { Log.Error(ex); } }
/// <summary> /// Creates a Enumerable of Appointment from a given Bundle. /// </summary> /// <param name="notificationData">the Bundle of an Intent containing a Enumerable of Appointments</param> /// <returns>the Enumerable of Appointment elements</returns> private IEnumerable <Appointment> extractAppointments(Bundle notificationData) { string data = notificationData.GetString("Appointments"); if (String.IsNullOrEmpty(data)) { return(new List <Appointment>()); } return(JsonConvert.DeserializeObject <IEnumerable <Appointment> >(data)); }
protected override void InitVariables() { Bundle bundle = Intent.Extras; if (bundle != null) { scopeId = bundle.GetInt("scopeId"); scopeName = bundle.GetString("scopeName"); } }
protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); if (intent != null && intent.Extras != null) { Link = intent.GetStringExtra("title"); Rate = intent.GetStringExtra("body"); if (string.IsNullOrEmpty(Link)) { Bundle bundle = intent.Extras; String user_name = bundle.GetString("data"); Link = bundle.GetString("title"); Rate = bundle.GetString("body"); //extras.GetString("tag"); } } }
protected override void OnRestoreInstanceState(Bundle savedInstanceState) { base.OnRestoreInstanceState(savedInstanceState); if (savedInstanceState != null) { savedInstanceState.Get() statusTextView.Text = savedInstanceState.GetString(StatusKey); SetStatus($"{ActivityName} Restored instance state"); } }
private static bool GetBoolFromBundle(Bundle b, string key, bool defaultValue) { bool boolValue; if (!Boolean.TryParse(b.GetString(key), out boolValue)) { boolValue = defaultValue; } return(boolValue); }
void UpdateValuesFromBundle (Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet ().Contains (ADDRESS_REQUESTED_KEY)) { mAddressRequested = savedInstanceState.GetBoolean (ADDRESS_REQUESTED_KEY); } if (savedInstanceState.KeySet ().Contains (LOCATION_ADDRESS_KEY)) { mAddressOutput = savedInstanceState.GetString (LOCATION_ADDRESS_KEY); DisplayAddressOutput (); } } }
public override void OnMessageReceived(string from, Bundle data) { // Extract the message received from GCM: var title = data.GetString("title"); var TMDBID = data.GetString("TMDBID"); var message = data.GetString("message"); Log.Debug("MyGcmListenerService", "From: " + from); Log.Debug("MyGcmListenerService", "Message: " + message); // Forward the received message in a local notification: //Can send all JSON here and then parse if (title != null) { SendNotification(message, TMDBID, title); } else { SendNotification(message, TMDBID); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Create your application here if(bundle != null) { string s = bundle.GetString ("key"); } string ss = Intent.GetStringExtra ("key"); }
public override void Handle(Bundle bundle) { //���������������������Ϣ�ı��� var title = bundle.GetString(JPushInterface.ExtraTitle); //���������������������Ϣ���� var msg = bundle.GetString(JPushInterface.ExtraMessage); //������������������ĸ����ֶΡ����Ǹ� JSON �ַ����� //��Ӧ API ��Ϣ���ݵ� extras �ֶΡ� //��Ӧ Portal ������Ϣ�����ϵġ���ѡ���á���ĸ����ֶΡ� var extra = bundle.GetString(JPushInterface.ExtraExtra); //��������������������������͡� //��Ӧ API ��Ϣ���ݵ� content_type �ֶΡ� var contentType = bundle.GetString(JPushInterface.ExtraContentType); //SDK 1.4.0 ���ϰ汾֧�֡� //��ý��ͨ��Ϣ�������غ���ļ�·�����ļ����� var richFilePath = bundle.GetString(JPushInterface.ExtraRichpushFilePath); //SDK 1.6.1 ���ϰ汾֧�֡� //Ψһ��ʶ��Ϣ�� ID, �������ϱ�ͳ�Ƶȡ� var msgID = bundle.GetString(JPushInterface.ExtraMsgId); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); imageViewHelper = new ImageViewHelper(this); SetContentView(Resource.Layout.Storage); loadPhotoButton = FindViewById<Button>(Resource.Id.loadPhotoButton); createDocButton = FindViewById<Button>(Resource.Id.createDocButton); if (bundle != null) { currentImageUri = Android.Net.Uri.Parse(bundle.GetString("current_image_uri", string.Empty)); } else { currentImageUri = null; } // This button lets a user pick a photo from the Storage Access Framework UI loadPhotoButton.Click += (o, e) => { // I want data from all available providers! Intent intentOpen = new Intent(Intent.ActionOpenDocument); // filter for files that can be opened/used intentOpen.AddCategory(Intent.CategoryOpenable); //filter results by mime type, if applicable intentOpen.SetType("image/*"); StartActivityForResult(intentOpen, read_request_code); }; // This button takes a photo and saves it to the Storage Access Framework UI // The user will be asked what they want to name the file, // and what directory they want to save it in createDocButton.Click += (o, e) => { Intent intentCreate = new Intent(Intent.ActionCreateDocument); intentCreate.AddCategory(Intent.CategoryOpenable); // We're going to add a text document intentCreate.SetType("text/plain"); // Pass in a default name for the new document - // the user will be able to change this intentCreate.PutExtra(Intent.ExtraTitle, "NewDoc"); StartActivityForResult(intentCreate, write_request_code); }; }