Tag: xamarin.android

Xamarin.android-如何更快地加密/解密图像

我希望用户从图库中选择图像/video,并在我的应用中保护他们的图像。 为此,我加密了这些图像。 图像加密工作正常(我想是这样!)。 8MB图像需要1.5到2秒。 video怎么样? video可能是GB。 所以这需要很多时间。 即使在加密/解密中,我也必须对每个图像执行操作,这可能会导致内存问题。 这个链接帮助我实现了这一目标。 如果你看,ES文件浏览器还提供图像/video的加密和解密。 它只需几秒钟即可完成GB的操作。 那么我能知道这些人使用哪种技术/算法吗? 或者即使我以自己的方式使用,是否有任何技巧可以让它更快? 或者有没有其他方法使用户无法访问文件? 更改MIME类型是否有效? 即使我通过添加更改扩展名或隐藏它。 在文件名之前,用户仍然可以在某些文件资源管理器中查看图像。 实际上对于xamarin ,我没有找到任何与加密解密文件相关的post/博客。 它们提供的只是字符串解决方案。 如果有人指导我解决这个问题,我将非常感激。 编辑 您好,@ Joe Lv,正如我所说的那样,我尝试了加密速度慢但解密速度非常快的方法。 所以我实现了用于加密事物的相同解密技术。 它的工作原理!! 但我想知道这是否有效。 现在我的加密方法如下所示: public void encrypt(string filename) { // Here you read the cleartext. try { File extStore = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryMovies); startTime = System.DateTime.Now.Millisecond; Android.Util.Log.Error(“Encryption Started”, extStore + “/” + […]

使用HttpClient进行头部请求

我正在向Google.com提出HEAD请求。 这是我的代码: using (var client = new HttpClient()) { var m = new HttpRequestMessage(HttpMethod.Head, “http://google.com”); var resp = await client.SendAsync(m); return true; } 当我执行此代码时,我得到以下exception: System.Net.WebException:请求需要缓冲数据才能成功。 在System.Net.HttpWebRequest.Redirect(System.Net.WebAsyncResult结果,HttpStatusCode代码,System.Net.WebResponse响应)[0x00000] in:0 在System.Net.HttpWebRequest.CheckFinalStatus(System.Net.WebAsyncResult result)[0x00000] in:0 在System.Net.HttpWebRequest.SetResponseData(System.Net.WebConnectionData data)[0x00000] in:0 我无法理解为什么… Google接受Head请求,因为使用Postman我得到200 OK代码 你能帮助我吗?

Xamarin如何从android项目打开xamarin表单页面?

我想从Xamarin Android项目打开Xamarin表单页面。 在android项目中,我创建了太棒项目图像,我在这里调用事件从Xamarin表单项目打开页面。 这是我的MainActivity.cs toolabar图像项实现: public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { private IMenu CurrentMenu { get; set; } private ImageView imgSmallC { get; set; } public override bool OnCreateOptionsMenu(IMenu menu) { ActionBar.DisplayOptions = ActionBarDisplayOptions.HomeAsUp | ActionBarDisplayOptions.ShowCustom | ActionBarDisplayOptions.ShowTitle | ActionBarDisplayOptions.ShowHome; LayoutInflater inflater = (LayoutInflater)ActionBar.ThemedContext.GetSystemService(LayoutInflaterService); View customActionBarView = inflater.Inflate(Resource.Layout.actionbar_custom_view_done, null); imgSmallC = (ImageView)customActionBarView.FindViewById(Resource.Id.ImgSmallC); imgSmallC.Click += (object […]

为什么Xamarin等效的EditText.getText()返回一个字符串?

我是一个新的Xamarin.Android开发人员。 我最近阅读了一些在派生类中使用EditText方法的Java代码。 其中一个派生类’方法看起来像这样: private void checkMatchingBracket(int paramInt) { getText().removeSpan(this.openBracketSpan); getText().removeSpan(this.closeBracketSpan); … } 这让我感到困惑,因为我认为getText()返回了一个String ,因为EditText.Text属性是此类’Xamarin对应物中的string 。 然而,这种情况并非如此; 似乎getText()返回一个Editable ,它看起来像一个可变的字符串类型,它提供了额外的function,例如将“spans”附加到某些文本区域( SpannableString ?)。 我的猜测是Xamarin返回的string已从此Editable的文本中复制过来,因此我无法真正修改原始的Editable并使用其API。 我对么? 因为我正在使用Xamarin,是否无法访问原始的Editable ? 编辑:我想要做的具体事情是EditText本的颜色区域。 我发现这个答案使用跨度来实现这个目的: TextView textView = (TextView)findViewById(R.id.mytextview01); Spannable WordtoSpan = new SpannableString(“partial colored text”); WordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 2, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(WordtoSpan); 但是,Xamarin的API EditText.Text.set只接受一个.NET string ,它显然没有颜色或“跨度”的概念。

如何使用visual studio和xamarin关闭活动android

我在我的项目上有登录,注册和主页。 我使用StartActivity(typeof(Register)); 打开注册页面。 当用户已插入数据并单击注册按钮时,我使用StartActivity(typeof(MainActivity)); 再次返回登录页面。 当我点击手机上的后退按钮时,它返回注册页面>登录页面>然后退出。 我想在打开新页面后关闭已创建的活动。 我的第二个问题,我有退出按钮,如何使用退出按钮关闭我的应用程序? 我正在使用Visual Studio 2015和Xamarin开发Android应用程序。

ViewModel中的构造函数

是否可以在视图模型中使用构造函数,初始化数据服务? (不要误解我的意思,我的数据服务正在访问数据存储的Web服务)这样的事情(问我因为我得到ViewLoader引发的exception“无法加载ViewModel ……”而且它没有显示整个例外…): using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.ObjectModel; using Cirrious.MvvmCross.ViewModels; using Cirrious.MvvmCross.Commands; using MobSales.Logic.DataService; using MobSales.Logic.Base; using MobSales.Logic.Model; namespace MobSales.Logic.ViewModels { public class CustomersViewModel:MvxViewModel { ICustomerService custService; public CustomersViewModel(ICustomerService custService) { this.custService = custService; if (custService != null) { custService.LoadCustomerCompleted += new EventHandler(custService_LoadCustomerCompleted); } loadCustomerCommand = new MvxRelayCommand(LoadCustomer); loadCustomerCommand.Execute(); } […]

System.IO.FileNotFoundException:无法加载程序集…也许在Mono for Android Profile中不存在?

我在尝试从Visual Studio编译我的Android应用程序时收到以下错误(我正在使用Xamarin插件)。 错误2加载程序集时出现exception:System.IO.FileNotFoundException:无法加载程序集’PresentationUI,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35’。 也许它在Mono for Android配置文件中不存在? 文件名:Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference)上的’PresentationUI.dll’ 参考,ReaderParameters参数)在Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 程序集,AssemblyDefinition程序集,布尔topLevel)在Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(List`1 程序集,AssemblyDefinition程序集,布尔topLevel)在Xamarin.Android.Tasks.ResolveAssemblies.Execute() 我环顾四周,发现这个论坛post看起来像一个类似的问题。 我找不到PresentationUI.dll程序集。 有关为什么我会收到此错误以及如何解决此问题的任何建议? 更新 我发现问题实际上来自于使用来自Microsoft.Practices.Prism.dll的DelegateCommand,是因为Xamarin不支持这个程序集吗? 干杯,

在Xamarin Cross Platform Application中使用WCF服务

我创建了一个WCF服务,它从SQL数据库中检索数据,并可以将数据更新和修改为SQL数据库。 我试图从xamarin for android和xamarin for iOS调用WCF方法。 我搜索了一个例子,如何从WCF服务调用PUT和POST方法,通过xamarin for android和xamarin for iOS但没有运气。 我在下面添加了WCF代码以供参考。 …甚至创建了Web API,但所有使用Web API的示例和教程都是关于如何调用GET方法的。 我没有看到任何参考文档,它将展示如何通过跨平台从WCF或Web api调用PUT或Post方法。 我通过Fiddler测试了WCF服务并且工作正常。 下一步将是什么..我已经使用xamarin文档中提到的SlsvcUtil.exe为此Web服务创建了代理。 有人发布了一个xamarin.Android的例子,它将从下面的wcf服务中调用Update或delete方法。正在寻找help.Service包含webHttp绑定。 WCF Service1.svc.cs using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; public class Service1 : IService1 { public List GetDeptsList() { using (DeptDBEntities entities = new DeptDBEntities()) { return entities.Depts.ToList(); […]

SQLite错误Mono.Data.Sqlite.SqliteStatement.BindParameter中提供给命令的参数不足

我有一个简单的插入语句到MonoDroid上的SQLite数据库中的表。 它说,当插入数据库时 SQLite错误Mono.Data.Sqlite.SqliteStatement.BindParameter中提供给命令的参数不足 我认为有一个错误,或错误消息是误导。 因为我只有5个参数而且我提供了5个参数,所以我看不出这是怎么回事。 我的代码如下,任何帮助将不胜感激。 try { using (var connection = new SqliteConnection(ConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandTimeout = 0; command.CommandText = “INSERT INTO [User] (UserPK ,Name ,Password ,Category ,ContactFK) VALUES ( @UserPK , @Name , @Password , @Category , @ContactFK)”; command.Parameters.Add(new SqliteParameter(“@Name”, “Has”)); command.Parameters.Add(new SqliteParameter(“@Password”, “Has”)); command.Parameters.Add(new SqliteParameter(“@Cateogry”, “”)); […]

找不到Xamarin.Forms.Platform.Android.LabelRenderer(xamarin表单)的构造函数

当我在我的samsumg galaxy s5设备中测试我的应用程序时,我在pcl项目的xaml中有一个图像列表我这样做:我进入列表的页面,然后我按下操作栏上的后退按钮…我做了很多次……然后,它发生了: System.NotSupportedException:无法从本机句柄0x20e0001d(key_handle 0x42433c30)激活Xamarin.Forms.Platform.Android.Platform + DefaultRenderer类型的实例。 要么 无法从本机激活Xamarin.Forms.Platform.Android.LabelRenderer类型的实例 更新 我添加了这个脚本: using System; using Android.Runtime; using Xamarin.Forms; using Xamarin.Forms.Platform.Android; [assembly: ExportRenderer(typeof(Xamarin.Forms.Label), typeof(LabelRenderer))] namespace neoFly_Montana.Droid { /// /// This renderer was added to resolve a bug that crashed the application in known case /// Bug 36285 – Android App (Always) Crashes After Navigating Away From Page […]