Tag: xamarin

Xamarin在活动之间传递数据

我无法在2个活动之间共享数据: 活动1 homeButton.Click += delegate { var second = new Intent(this, typeof(SecondPage)); second.PutExtra(“reg”, “qwe”); StartActivity (typeof(SecondPage)); } Acitvity2(SecondPage) string txt = Intent.GetStringExtra (“reg”) ?? “null”; Console.WriteLine (txt); 仍然得到null,有什么建议吗?

用Xamarin表格解析数据

我想获取集合href(CustomerDemographics,Customers,Employees,Order Details)中的名称来填充listview。 我想知道如何在Xamarin平台或C#中解析这些信息。 我对这个环境很陌生。 我有经验如何用目标c解析本机ios中的json数据,但这是我第一次看到这种类型的数据。

我需要做些什么来使这个代码在Portable Class Library中工作?

我想知道可移植类库在function上是否比Compact Framework更受限制。 我正在尝试将CF / Windows CE应用程序(在手持设备上运行)移植到Xamarin解决方案,该解决方案将针对Android,iOS,Windows Phone以及其他东西。 但是,我遇到的一个问题是这个遗留代码(在CF下运行): public static List GetXMLFiles(string fileType, string startingDir) { const string EXTENSION = “.XML”; string dirName = startingDir; // call it like so: GetXMLFiles(“ABC”, “\\”); <= I think the double-whack is what I need for Windows CE device…am I right? var fileNames = new List(); try { foreach […]

警报每次打开应用程序时都会关闭

我无法弄清楚为什么每当我打开我的应用程序时,我的通知设置为关闭闹钟就会被取消。 我只在特定的日期和时间设置日历。 不仅是我的闹钟在日历的指定时间和星期几甚至没有响起。 我的闹钟甚至需要服务吗? 我试图确保即使应用程序关闭也会关闭。 下面的代码(MyService)在MainActivity onCreate()中调用。 [Service] public class MyService : Service { //const int NOTIFICATION_ID = 9000; public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { SetAlarm(); return StartCommandResult.Sticky; } private void SetAlarm() { //setting Calendar Java.Util.Calendar calendar = Java.Util.Calendar.Instance; calendar.Set(Java.Util.CalendarField.DayOfWeek, 1); calendar.Set(Java.Util.CalendarField.HourOfDay, 02); calendar.Set(Java.Util.CalendarField.Minute, 15); AlarmManager manager = (AlarmManager)GetSystemService(Context.AlarmService); Intent managerIntent; […]

Android语音识别将数据传回Xamarin Forms

我现在真的卡住了,对Xamarin来说我是一个新手。 我使用Xamarin Forms开发具有语音识别function的应用程序。 我创建了一个带有按钮和输入框的简单UI。 工作: 按下按钮并显示带语音识别的弹出窗口 将所说的单词读成var 不工作: 将数据传递回Xamarin Forms UI(条目) StartPage.xaml.cs: private void BtnRecord_OnClicked(object sender, EventArgs e) { WaitForSpeechToText(); } private async void WaitForSpeechToText() { EntrySpeech.Text = await DependencyService.Get().SpeechToTextAsync(); } ISpeechToText.cs: public interface ISpeechToText { Task SpeechToTextAsync(); } 调用本机代码。 SpeechToText_Android.cs: public class SpeechToText_Android : ISpeechToText { private const int VOICE = 10; public SpeechToText_Android() […]

MvvmCross – MvxListView绑定多次点击

我正在使用MvvmCross开发一个应用程序,我在Android应用程序中遇到问题,设置绑定以捕获构成MvxListView项目的两个不同控件中的单击操作。 ViewModel中所有数据的绑定都可以正常工作这是我的FavouritesView的AXML 而MvxItemTemplate在这里: 这是我的FavouritesViewModel: using System; using Cirrious.MvvmCross.Plugins.Messenger; using MyApp.Core.Managers; using MyApp.Core.Services; using System.Collections; using MyApp.Core.Domain; using System.Collections.Generic; using Cirrious.MvvmCross.ViewModels; using System.Collections.ObjectModel; using System.ServiceModel.Channels; using Cirrious.CrossCore; using MyApp.Core.Messages; using MyApp.Core.Helpers; namespace MyApp.Core.ViewModels { public class FavouritesViewModel: StandardsViewModel { private IFavouritesService _favouritesService; public FavouritesViewModel (ITextService textService, IMvxMessenger messenger, ISettingsManager settingsManager, IPageService pageService, IFavouritesService favouriteService): base(textService, messenger, […]

在xamarin中启用ARC

大多数安全和渗透工具都会报告ARC是否未启用。 fobjc-arc flag is not Found 据我所知,我们不能在xamarin中这样做,因为我们这里没有构建设置。 此标志只能在构建设置中设置。 即使我们可以,它也行不通,因为xamarin使用C#和MRC来自行管理内存。 任何人都可以解释我如何做或不做或我的理解是错误的 编辑: 我们可以通过构建设置将ARC打开为完整项目 CLANG_ENABLE_OBJC_ARC=YES 但是在xam studio中无法做到这一点…在mtouch中设置值也会引发错误

创建Xamarin.Forms跨平台应用程序时,“此项目需要加载Visual Studio更新”错误

当我在Windows 8.1上使用Visual Studio Community 2015 Community创建Xamarin.Forms应用程序时,它会在加载时显示此错误: A problem was encountered creating the sub project ‘App1.WinPhone’. This project requires a Visual Studio update to load. Right-click on the project and choose ‘Download Update’ 我已安装所有可用的更新并尝试新安装的Windows。 注意:我在表单中遇到此错误。 我该如何解决这个错误? 注意:解决方案资源管理器中没有“下载更新”选项。

如何刷新导航上的一个但最后一个ContentPage

通常,使用NavigationStack中的一个弹出当前页面: Navigation.PopAsync( true ); 如何使用Navigation重绘当前页面之前的页面? 背景:当前页面改变了需要在一页但最后一页重新呈现的内容。

Xamarin(Android)unit testing在Visual Studio 2017中

我正在使用Visual Studio 2017来开发Xamarin Android应用程序。 我想只添加逻辑的简单unit testing。 为此,我尝试使用unit testing添加“unit testing应用程序(Android)”或“类库(Android)”项目,但没有一个工作。 unit testing应用程序(Android) 我将新项目添加到我的“unit testing应用程序(Android)”类型的解决方案中。 生成的项目包含带有样本测试的TestsSample类,但我不知道如何启动它们。 我安装了ReSharper,但是当右键单击项目/类时,我没有运行测试的选项。 当我进入“测试” – >“运行” – >“所有测试”时,解决方案已经构建,但没有更多的事情发生。 带有nUnit的类库(Android) 另一个试验是在解决方案中添加“类库(Android)”类型的新项目。 之后,我安装了nUnit nuget软件包( install-package nunit安装包’nunit.3.6.1’,关于项目’MoneyBack.Tests’,目标是’MonoAndroid,Version = v6.0’),安装成功。 我添加了以下类: using NUnit.Framework; namespace MoneyBack.Tests { [TestFixture] public class Class1 { [Test] public void SampleTest() { Assert.IsTrue(true); } } } 现在,当右键单击测试项目时,我看到ReSharper的选项“Run Unit Tests”,所以我点击它并得到以下exception: 难道我做错了什么 ? 或者这是VS2017的问题? 我不知道我是否应该安装VS2015或者有一些解决方案。 […]