I want to have 2 android projects in my solution. 1 for google another for amazon store. 2 projects have same resources and mostly other classes. what is the best project type to share those? I tried using android class library but it doesnt work. i am getting different errors although I installed support libraries. can somebody shed some lights on me please?
how to share resources between 2 android projects?
Unable to solve the 'System.AccessViolationException' while validating Sign In credentials..
Execution stops when I am clicking the Sign In with the following exception output:
An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
The program '[12516] Day2_SQLite.UWP.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
using System;
using System.Collections.Generic;
using System.Linq;
using SQLite;
using Day2_SQLite.Models;
namespace Day2_SQLite
{
public class RegistrationRepository
{
public string StatusMessage { get; set; }
private bool SigninIsValid;
SQLiteConnection conn,conn_validate;
public RegistrationRepository(string dbPath)
{
// TODO: Initialize a new SQLiteConnection
conn = new SQLiteConnection(dbPath);
conn_validate = new SQLiteConnection(dbPath);
// TODO: Create the registration table
conn.CreateTable<Registration>();
}
public void AddNewPerson(string name, string email, string password, string gender, string mobile)
{
int result = 0;
try
{
//basic validation to ensure a name was entered
if (string.IsNullOrEmpty(name))
throw new Exception("Valid name required");
else if (string.IsNullOrEmpty(email))
throw new Exception("Valid email required");
else if (string.IsNullOrEmpty(password))
throw new Exception("Valid password required");
else if (string.IsNullOrEmpty(gender))
throw new Exception("Valid gender required");
else if (string.IsNullOrEmpty(mobile))
throw new Exception("Valid mobile no. required");
// TODO: insert a new person into the Person table
result = conn.Insert(new Registration { Name = name, Email = email, Password = password, Gender = gender, Mobile = mobile });
StatusMessage = string.Format("{0} record(s) added [Name: {1}]", result, name);
}
catch (Exception ex)
{
StatusMessage = string.Format("Failed to add {0}. Error: {1}", name, ex.Message);
}
}
public IEnumerable<Registration> GetPeople(string email)
{
// TODO: return a list of people saved to the Person table in the database
try
{
var result = conn.Query<Registration>("select * from registration where Email=?", email);
return result;
}
catch(Exception ex)
{
StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
}
return null;
}
public bool LoginValidate(string email, string password)
{
SigninIsValid = false;
try
{
var data = conn_validate.Table<Registration>();
var found = data.Where(x => x.Email == email && x.Password == password).FirstOrDefault();
if (found != null)
{
SigninIsValid = true;
}
}
catch (Exception ex)
{
StatusMessage = string.Format("Failed to retrieve data. {0}", ex.Message);
}
return SigninIsValid;
}
}
}
Thanks in advance
Extract Cookie from Web Response in Xamarin.Forms
How can we get cookie from the response header? Is there any way to get cookie other than from web response.
For me web response cookie count is 0.
WebResponse webResponse = request.GetResponse();
CookieContainer cookie = request.CookieContainer;
// here cookie is null
Please help.
How to do dependency injection in App.xaml using Prism
I need to check a db entry to decide which Navigation page to open on App startup. How can I access a service from the container to get the flag’s value?
If (isProvisioned)
{
await NavigationService .navigateasync(“Navigation/main”);
}
else
{
await NavigationService .navigateasync(“Navigation/signup”);
}
Private static bool IsProvisioned()
{
//1. Call service to get value
// 2. Set return to value
}
In-App Purchase failed submit app on Store
I have ask this question on MSDN Forum this is link of MSDN, I post here to find more solution!
My app is live on Microsoft Store few month ago. Now when I release update it's failed. I only change some grammar, I don't change any thing about In App Purchase. But I get this warning from Microsoft. I using Plugin.InAppBilling of Jame I think he is a Microsoft Staff here is the link
Please take the following action
We reviewed your submission and identified some changes that are needed before we can publish or update the app. Please make these changes and resubmit your app. For more information, contact reportapp@microsoft.com Please include your app ID so we can act quickly.
App Policies: 10.8.1 In-App Purchase: Digital Goods & Services
Notes To Developer
Your app enables in-app purchase of digital goods or services but does not use the Microsoft Store in-app purchase API.
Tested Devices: Windows 10 Desktop, Windows 10 Mobile
Please Note
Your current certification results might differ from earlier submissions because Windows Store policy requirements can change over time. When policies change, we might re-test according to the new requirements regardless of the submission type. Please always rely on your most recent certification results.
Google playstore in app purchase unsuccessful. Paid 60php for it.
Xamarin.Forms.UTemplates
Checkout my new Visual Studio Extension for creating MVVM projects using Unity
- Login App
- Social App
- Empty MVVM App
https://marketplace.visualstudio.com/items?itemName=mohamedalinouira.XamarinFormsUTemplates
Xamarin.Forms.MVVMLight
* Login App
* Social App
* Empty MVVM App
https://marketplace.visualstudio.com/items?itemName=mohamedalinouira.XamarinFormsMVVMLight
Xamarin.Forms.Templates extension for Visual Studio 2017
Xamarin.Forms.Templates extension for Visual Studio 2017:
https://marketplace.visualstudio.com/items?itemName=mohamedalinouira.XamarinFormsTemplates
*Provides a collection of templates for Xamarin.Forms projects.
*Uses several NuGet packages (Navigation, Controls, Behaviors, Extensions, Converters) that allow you to quickly create Xamarin.Forms applications using MVVM Design Pattern :
Xamarin.Forms.Navigation : https://www.nuget.org/packages/Xamarin.Forms.Navigation/
Xamarin.Forms.ToolKit.Controls : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Controls/
Xamarin.Forms.ToolKit.Behaviors : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Behaviors/
Xamarin.Forms.ToolKit.Converters : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Converters/
Xamarin.Forms.ToolKit.Extensions : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Extensions/
Thank you for having taken your time to provide us your valuable feedback !
Mohamed Ali NOUIRA
www.github.com/medalinouira
OxyPlot initialize renderer error
I need to do some basic plotting in my App with the help of the OxyPlot NuGetPackage extension. I have followed the online tutorials on how to set it up and as far as i can tell i did it correctly. I put the Init call to initiate the renderer right after the Xamarin.Forms.Forms.Init in every of the 3 Folders(Android, IOS, UWP) like so(Android as example):
base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); LoadApplication(new App());
Now everytime i start the app i get an exception along the lines of:"Visualization error. Dont forget to initialize renderer in Android MainActivity.cs" which I clearly did. I'm getting really frustrated at this as i cant find any fix on the Interwebs and other plotting libraries seem way too cumbersome to use. I would appreciate any help i can get!
Thanks beforehand
Deleting the Media file from storage
Hi,
I have been using the Media Plugin to capture the photo from android device using XF. I have noticed that the files are stored in specified directory. My question is that how can I delete these files from the storage after usage how can I do that.
I tried to delete the file after showing but the files are still in "samples" directory.
var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
CompressionQuality = 92,
AllowCropping = true,
SaveToAlbum = true,
Directory = "Samples",
Name = (Guid.NewGuid().ToString("N") + ".jpg")
});
if (photo != null)
{
imgPhoto.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
if (File.Exists(photo.Path))
{
File.Delete(photo.Path);
}
photo.Dispose();
}`
the File.Delete(photo.Path) statement executes without error however the actual file still remains in the storage.
If its not possible at this level is there a way to delete all files in specific directory on launch or close of the application? How can I access the Folder path?
Thanks in advance
while calling rest api get url getting Newtonsoft.Json.JsonSerializationException
i am getting this error
"Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'servicecall.Items4+RootObject' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\nPath '', line 1, position 1.\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract) [0x00058] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00012] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0007f] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at servicecall.fourthlisturl+d__8.MoveNext () [0x000ce] in \MySaiworkSpace\servicecall\servicecall\servicecall\fourthlisturl.xaml.cs:46 "
How to implement the chat bot application using DirectLine Api of MicroSoft ??
I need to implement the chat bot using directline api
Graphics, SkiaSharp
Hi all,
I am currently looking at the SkiaSharp Example here: https://developer.xamarin.com/guides/cross-platform/drawing/introduction/#Obtaining_an_SKCanvas.
It seem's easy enough and i implemented my code as the following:
public TestController()
{
InitializeComponent();
DrawXamagon();
}
protected void DrawXamagon() {
using (var surface = SKSurface.Create(width: 640, height: 480, colorType:SKColorType.Rgb565, alphaType: SKAlphaType.Premul))
{
SKCanvas canvas = surface.Canvas;
// clear the canvas / fill with white
canvas.Clear(SKColors.White);
// set up drawing tools
using (var paint = new SKPaint())
{
paint.IsAntialias = true;
paint.Color = new SKColor(0x2c, 0x3e, 0x50);
paint.StrokeCap = SKStrokeCap.Round;
// create the Xamagon path
using (var path = new SKPath())
{
path.MoveTo(71.4311121f, 56f);
path.CubicTo(68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
path.LineTo(43.0238921f, 97.5342563f);
path.CubicTo(41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
path.LineTo(64.5928855f, 143.034271f);
path.CubicTo(65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
path.LineTo(114.568946f, 147f);
path.CubicTo(117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
path.LineTo(142.976161f, 105.465744f);
path.CubicTo(144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
path.LineTo(121.407172f, 59.965729f);
path.CubicTo(120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
path.LineTo(71.4311121f, 4056f);
path.Close();
// draw the Xamagon path
canvas.DrawPath(path, paint);
}
}
}
I have no errors and the code steps through fine, but noting is displayed (It should display the Xamarin logo). There dosen't seem to be much more to the example, am i supposed to initialise a canvas or Skview in the XAML, or is there any mistakes anybody can see in my example?
Thank you in advanced.
Update UI from async Action
Hi,
I'm currently uisng a command to allow the user to choose some files.
PickFilesCommand = new Command(PickFiles);
When I want to update my UI it dosen't work. The begin Device.BeginInvokeOnMainThread
is executed at the end of my method. The problem is that I need my method to be async because of UWP.
` private async void PickFiles()
{
// Récupération des fichiers choisis par l'utilisateur
List selectedFiles = await DependencyService.Get().SelectFilesAsync();
if(selectedFiles.Count > 0)
{
Device.BeginInvokeOnMainThread(()=> { IsLoading = true; });
//Work with files ... (sychronous)
Device.BeginInvokeOnMainThread(()=> { IsLoading = false; });
}
}`
What I want is to update my UI at the start of my method and at the end.
How can I do it ?
Thanks
Image ScrollView with HorizontalFill
Hello Everyone!
I'm trying to make a scrollView with a couples of image in it but it's not showing how I want it.
Basicaly, I need each image to stretch to max width and keep aspect ratio. Ex : screen width is 1000px, img is 10x40, I need it to stretch to 1000x4000
I have tried many things but it does not seems to work.
Here is part of my code :
<Grid Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="#2D2D2D" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ScrollView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout x:Name="imgScroll" VerticalOptions="FillAndExpand">
<Image Source="conso_jeune_drogue.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />
<Image Source="conso_pas_fort.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />
<Image Source="conso_jeune_drogue.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />
<Image Source="conso_pas_fort.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />
</StackLayout>
</ScrollView>
</Grid>
so this is the structure, a stack in a scroll in a grid
I have tried setting minimumwidth and minimumHeight but the result is the same.
So I tried adding images in the code as such :
foreach (string s in imgToLoad)
{
var newImg = new Image();
newImg.Source = s;
var ratio = newImg.Height / newImg.Width;
newImg.MinimumWidthRequest = Application.Current.MainPage.Width - 20;//width - margin
newImg.Margin = 10;
newImg.HorizontalOptions = LayoutOptions.FillAndExpand;
newImg.VerticalOptions = LayoutOptions.FillAndExpand;
imgScroll.Children.Add(newImg);
}
where imgScroll is my scrollView and imgToLoad are my images's names.
And that is where it start to get weird. with this, it work in my android emulator ( nexus 6, api 7.0) but it does not on my phone using xamarin live ( galaxy s8, API 8.0)
Unfortunately I cant post images because I haven't been on this forum for long enough
so its on imgur and the link is
imgur.com/QtRRcS5 for the one that is not working
imgur.com/WJdkpFA for the one that is working
Any idea? is it supposed to work but somehow xamarin live is having problem?
If you need any clarifications do not hesitate,
Thanks a lot!
FlatButton renderer for android
Hello,
I use this renderer in my Droid project for get flat button but after an OS reinstall and an update packages VS it's doesn't work whereas before this renderer has working, any ideas?
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using Android.Content;
[assembly: ExportRenderer(typeof(Button), typeof(MyProject.Droid.Renderers.FlatButtonRenderer))]
namespace MyProject.Droid.Renderers
{
public class FlatButtonRenderer : ButtonRenderer
{
// Constructors
public FlatButtonRenderer(Context context) : base(context) { }
// Methods
protected override void OnDraw(Android.Graphics.Canvas canvas)
{
base.OnDraw(canvas);
}
}
}
Best regards
XLabs NullReference with Xamarin Forms on Android
I have a problem using XLabs in combination with Xamarin.Forms under Android. I have a very simple sample project with two XAML Pages and ViewModels.
I ALWAYS get a NullReference exception after compiling with no errors in the LaunchApplication(new App()); method. (see StackTrace below).
UpdateActionBarBackgroundColor();
Perhaps XLabs in NOT compatible with the new Android 5.x or 6.x Material Design ? Because the XLabs base class XFormsApplicationDroid does not have the TabLayoutResource and ToolbarResource properties, so I have to comment them out ?
Here the absolut standard initialization code in the
public class MainActivity : XFormsApplicationDroid
{
protected override void OnCreate (Bundle bundle)
{
//TabLayoutResource = Resource.Layout.Tabbar;
//ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate (bundle);
var resolverContainer = new SimpleContainer();
resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice);
Resolver.SetResolver(resolverContainer.GetResolver());
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new App ());
}
}
StackTrace:
at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarBackgroundColor () [0x00010] in :0
at Xamarin.Forms.Platform.Android.Platform.set_CurrentNavigationPage (Xamarin.Forms.NavigationPage value) [0x000f1] in :0
at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x00063] in :0
at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in :0
at MVVMBase.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0004a] in /Users/marcoseraphin/Projects/MVVMBase/Droid/MainActivity.cs:35
I tried different version combinations:
XLabs: 2.0.5783
Xamarin.Forms: 2.0.1.6495
I also tested the current 2.2.0.45 Xamarin Forms and also different pre versions. But always the NullReference error at runtime.
Even the XLabs pre versions does not have the ToolbarResource property.
On GitHub are different opinions concerning some errors if it belongs to XLabs or Xamarin Forms.
Any ideas ?
Thanx
Marco
How can I implement localization in Xamarin.Forms Shared project in VS2017
I downloaded the samples provided by Xamarin docs and followed the tutorial but couldn't apply it to my VS17 shared project.
I can only add .resw resource files from VS17 to my Shared Project. I Also tried adding existing .resx files. Both formats are not recognized in my Shared Project where I need to set the culture and use them in my .xaml files.
Any idea on how to get localization working? Please share some code or sample in VS17 Xamarin.Forms Shared project.
Navigating from One Tab to another taking time - I am using custom control for Tab
I am creating App in Xamarin Form which has three Tabs and each tab has a content page
Page 1 - It has a chart control and a List view which is created using grid control.
Page 2 - It has just a List view which is created using the grid control
Page 3 - It also has just a List view which is created using the grid control
For tabs I am using button control in the Custom page which we will call as HeaderFooter page and this HeaderFooter page is inherited in each content page[ Page 1,Page 2,Page 3].
When we tab the Page 1 button an event gets fired in the HeaderFooter page,there I am creating the object for Page1 like
Page1 obj1 = new Page1();
In the Page 1 constructor I will get the data from SQLite DB frame the chart object and List view object.
Then I am passing the Page 1 object to Navigation
Navigation.PushAsync(obj1) ;
So the same process has been followed for all three tabs.
So the issue here is for navigating from one tab to other it is taking minimum 2.5 seconds.
For navigating to Page 1 it is taking 7.5 seconds as it has the charting control and List view control. [ data can be 1000 records]
For navigating to Page 2 it is taking 2.8 seconds as it has List view control [ data can be 100 records]
For navigating to page 3 it is taking 2.5 seconds as it has list view control and very less data [ data for now 4 records]
I would like to know why it is taking this much time and how can I improve the performance.
Note : I could not use the xamarin Tabs control because of the UI design.