Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

MediaPlugin Argument Exception Unable to get file location...

$
0
0

Xamarin Forms app for IOS and Android using MediaPlugin.
Only on some android instances this is not working and throwing the exception below.

The Argument Exeception thrown is:

"Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project."

Since AppCenter has no way of reporting handled exceptions properly, i have only an eventtype and no stacktrace, device info or anything, but my guess is it happens after calling
await CrossMedia.Current.TakephotoAsync(...)

The error suggests i have not setup the fileproviders properly, but the fileprovider info is exactly setup as provided in the readme files. It is working on all my Android test devices and emulators.

My file_paths.xml file:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <external-files-path name="my_images" path="Pictures" />
  <external-files-path name="my_movies" path="Movies" />
</paths>

And this is set in the AndroidManifest.xml:

<manifest...>
        <application...>
            <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.myappname.nl.fileprovider" android:exported="false" android:grantUriPermissions="true">
                    <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
                </provider>
        </application>
    </manifest>

What can be wrong on the problematic instances?


Performance issue when trying to dynamically change parts of the content of a page

$
0
0

**I have a pretty simple xamarin app. **

It's split into two sub-views/sub-pages, which splits the page 3/7 in height. This is done by a grid which holds two rowdefinitions and a contentview (BottomViewSubViewHolder) which is placed into Grid.Row=1 (bottom part).

Then I have a button for navigating the subviews, (which switches the bottom subview on tap).

What I do is that I simply switch the content of the BottomViewSubViewHolder. I set it with new different contentviews depending on how many taps.

It seems however that the intital tap, always takes longer, when the content is set, the app freeze for a couple of hundred milliseconds. After that first initial tap however, the following taps will not show any lag in the app.

This is all I do:
var view = new SubView1();
var viewModel = new SubViewModel1(new NavigationService());
view.BindingContext = viewModel;
bottomViewSubViewHolder.Content = view;

  • This worries me a bit. Have you guys experienced anything like this and do you know what to do about it?

  • Is there a better way of trying to change parts of a page dynamically? Should I Make bigger xaml-views and use IsVisible on parts of the view instead?

App crashes every now and again?

$
0
0

Xamarin.Forms question for Android. An app I created is crashing every now and again and I’m unsure why. Doesn’t happen much.

Whats the best way to view how and why your app crashed on an android device? Thanks in advance.

Xamarin forms splash screen visible navigate to another page

$
0
0

splash screen visible when navigate to new page in xamarin.forms android. i want remove or hide the background image

Sync data accross multiple devices (just like with iCloud on iOS)

$
0
0

What is the best way for an Android implementation to sync data accross multiple devices? I currently have iCloud implemented to iOS but now I still need an alternative for Android. My app is, at least now, only available in the Google Play Store but might be later added to Amazon for example.

Is there even an alternative that is similar to iCloud on iOS? Google Drive? Dropbox?

Understanding BottomNavigationView, XML menu and drawables

$
0
0

I'm have been trying to understand how to customize the BottomNavigationView by looking at an number of forum threads.
All of them uses an xml menu file located in the resources - menu folder.
These menues in turn referres to xml drawable files, like ic_dashboard_black_24dp.xml, ic_small_dog_white_24dp.xml, ic_home_white_24dp.xml and so on.
The xml files in the othe3r samples are never displayed in any of the samples so the contents of them is unknown.
Are these drawables part of som library or alike that I have to download/install?

In the files I have seen there seem to be a path part with a android:pathData for the actual image.
How are these vector strings created?

Best Regards
Peter Karlström
Sweden

Xamarin UITest does not clean my app on iOS

$
0
0

Hi all,

When I ran my tests on android the app always starts at the beginning and no prev configurations are set. But with iOS the app always starts with the page where it last has been. So when I ran test A and i'm on screen X and after that I ran test B then the app will start at screen X instead of the initial beginning screen.

I already set the AppDataMode to clear but this didn't do the trick.

Thanks in advance!

UWP compile error

$
0
0

I am recently unable to compile the UWP within the release configuration. I get the errors as below, which I read as being in relation to the xamarin.forms.element.

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : System.NotSupportedException: Cannot deserialize type 'Xamarin.Forms.Element' because it contains property 'RealParent' which has no public setter.

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.TypeDesc.CheckSupported()

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.TypeDesc.CheckSupported()

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.ReflectionAwareCodeGen.WriteReflectionInit(TypeScope scope)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.XmlSerializationWriterCodeGen.GenerateBegin()

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Hashtable assemblies, String outputDir, IEnumerable`1 referenceDirectories, String intermediateDir, Boolean loadAssembly)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[] types, XmlMapping[] mappings, CompilerParameters parameters, String outputDir, IEnumerable`1 referenceDirectories, String intermediateDir, Boolean loadAssembly)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[] types, String outputDir, IEnumerable1 referenceDirectories, String intermediateDir, List1 wcfSerializers, Boolean loadAssembly)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : at SerializationAssemblyGenerator.Program.Main(String[] args)

2>C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : ILT0032: Failed to compile serialization code. See the build log for error details.

Both the android and iOS counterparts can and have been distributed without problem.

I would appreciate any help at all as this has stopped us in our tracks to distribute to the windows store the latest build.


Bindable Properties

$
0
0

I have this Behavior I would set a label when the regex is match, my regex works fine, the color on entry change.
But for the label i would set, I don't know how use the bindable properties.

behavior.cs

 const string labelDefault = "Email isn't correct, please modify";
 const string labelValid = "Email is correct, please connect you";

static readonly BindablePropertyKey isValidLabel = BindableProperty.CreateReadOnly("IsValidLabel", typeof(string), typeof(LoginBehavior), labelDefault);

        public static readonly BindableProperty IsValidProperty = isValidLabel.BindableProperty;

        public string IsValidLabel
        {
            get { return (string)GetValue(IsValidProperty); }
            private set { SetValue(isValidLabel, value); }
        }

void OnEntryTextChanged(object sender, TextChangedEventArgs args)
        {
            Regex regex = new Regex(emailRegex);
            bool isValid = regex.IsMatch(args.NewTextValue);
            ((Entry)sender).TextColor = isValid ? Color.Default : Color.Red;
            this.IsValidLabel = labelValid;

        }

view.xaml

<StackLayout Padding="15">
                <Image Source="dose_landauer.png"/>
                <Label Text="Login"/>
                <Entry Text="{Binding User.Username}"
                       Placeholder="Username" x:Name="entryUsernameConnection">
                    <Entry.Behaviors>
                        <behavior:LoginBehavior/>
                    </Entry.Behaviors>
                </Entry>
                <Label Text="Password"/>
                <Entry Text="{Binding User.Password}"
                       Placeholder="Password"
                       IsPassword="True" x:Name="entryPwdConnection">
                </Entry>
                <Label Text="{Binding IsValidProperty}">
                </Label>
                <Button Text="Login" Command="{Binding ClickLogin}"/>
            </StackLayout>

Binding to a Command and Type Safety

$
0
0

Perhaps this is simply an uneducated question I am not sure. I use a number of Command Bindings similar to what is described here:
https://blog.xamarin.com/simplifying-events-with-commanding/

I like this approach quite a bit because it allows me to include virtually all code behind in the View Model. However, I am finding a few drawbacks that can sometimes cause problems.

1) When I bind a control in XAML the command (in this case "SquareRootCommand") does not refactor in Visual Studio with the attached view model. This causes problems when the command name gets renamed in the view model, leaving behind an orphaned control that no longer fires its intended command. Unfortunately, there are no compiler errors as I would have hoped. In fact it appears there not really any errors at run time either, Xamarin simply ignores the command.

2) Sometimes I forget to the declare the ICommand property in the view model as public. This again orphans the control because it can not reach the non public property. Again there are no compiler errors.
//Note the command is not public
ICommand SquareRootCommand { get; private set; }

Is this the intended behavior for Visual Studio or are there any plans to make the bound property/command in the XAML trigger a compiler error, similar to how an error is triggered if a XAML control EVENT is not properly found/wired up in the page code behind?

I understand the complexity that may exist since the design of the view model is not necessarily going to be defined the same way each time (it is not after all the code behind page file). However, is there an interface I should implement or a design practice that I should incorporate that may allow for more type safety in this regard?

Is it possible to wait for Device.BeginInvokeOnMainThread code to finish

$
0
0

Hello everyone,

In my code I have a task called "ShowMessageBoxAsync". I want to use this code to show (and await) the DisplayAlert to the user and return the result. Like this: var messageBoxResult = await View.ShowMessageBoxAsync("This is an error");

The code for the ShowMessageBoxAsync is:

    public async System.Threading.Tasks.Task<bool> ShowMessageBoxAsync(string message)
    {
        var result = false;
        Device.BeginInvokeOnMainThread(async () =>
        {
            result = await DisplayAlert("Error", message, "OK", "Cancel");
        });
        return result;
    }

Before I added the Device.BeginInvokeOnMainThread, the task gave me an Exception that it wasn't running on the main/UI thread. So after adding BeginInvokeOnMainThread, it started to work without exceptions. The problem, however, is that the code goes directly to the result, without waiting for the result of the "await DisplayAlert".

Is it possible return the value of "result" only after the Device.BeginInvokeOnMainThread code finishes?

Thanks in advance!

what form is this?

$
0
0

Greeting everyone, i am having hard time figuring this form, is it using listview or table? or something else?
can someone help me out?
thank you

Google OAuth 2 - How to get refresh token using Xamarin.Auth?

$
0
0

0
down vote
favorite
I'm using Xamarin.Auth to authenticate the user and have access to the Google Calendar API. I'm able to get an access token and do whatever I need. The problem is the access_token I receive expires after one hour. I looked for examples and information about this in several posts but I'm still not able to ask for new tokens. Here is the code I'm using in my Xamarin.Droid Project:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

    global::Xamarin.Forms.Forms.Init(this, bundle);
    LoadApplication(new App());

    #region [GoogleAuthentication]

    if (App.auth == null)
    {
        App.auth = new GoogleAuthenticator(App.WebApplicationClientID,
        new Uri("https://www.googleapis.com/plus/v1/people/me"),
        CalendarService.Scope.Calendar);
    }

    // We don't want to have to login every time, so we'll use the Xamarin.Auth AccountStore
    AccountStore store = AccountStore.Create(this);
    Account savedAccount = store.FindAccountsForService("google").FirstOrDefault();
    if (savedAccount != null)
    {
        App.auth.Account = savedAccount;
    }
    else
    {
        App.auth.Completed += (sender, args) =>
        {
            if (args.IsAuthenticated)
            {
                // Save the account for the future
                store.Save(args.Account, "google");
            }
        };

        Intent loginIntent = App.auth.GetUI(this);
        StartActivity(loginIntent);
    }

    #endregion [GoogleAuthentication]
}

The GoogleAuthenticator class implements OAuth2Authenticator as seen below:

public class GoogleAuthenticator
: OAuth2Authenticator
{
public GoogleAuthenticator(string clientId, Uri callbackUri, params string[] scopes)
: base(
clientId,
(scopes ?? Enumerable.Empty()).Aggregate(string.Empty, (o, s) => o + " " + s),
new Uri("https://accounts.google.com/o/oauth2/auth"),
callbackUri,
null)
{
Completed += (sender, args) =>
{
Account = args.Account;
};
}

public Account Account
{
    get;
    set;
}

public void ApplyAuthenticationToRequest(HttpWebRequest request)
{
    if (Account == null)
        throw new InvalidOperationException("You must be authenticated to make requests");

    string token = Account.Properties["access_token"];
    string type = Account.Properties["token_type"];
    request.Headers[HttpRequestHeader.Authorization] = String.Format("{0} {1}", type, token);
}

}

I tried changing the authorizationUrl adding the parameters approval_prompt=force and access_type=offline but it didn't work too.

How can I get the refresh_token using Xamarin.Auth?

Thanks.

Google OAuth2 - The access token has expired but we can't refresh it.

$
0
0

I am using Xamarin.Auth component and using OAuth2Authenticator i got access token, but not refresh token. When I uploads video using Youtube API it fails with an exception as: "The access token has expired but we can't refresh it".

Please help me****.

Thanks in Advance!!!

Configure the Button's text color (click effect) when a user clicked on it

$
0
0

Hi guys,

I am using two buttons into one of my pages' TitleView and I would like to configure their text color when a user is clicking on them.
I am talking about the effect proving that the event happened correctly.

The color being display by the effect is way too dark and since my buttons (white as text color) are located into my Toolbar (dark blue as background color), it doesn't create a nice result. Any idea to do that ? A renderer maybe ?

I thank you in advance for your time and your response !
Best regards,


Button text always showing in uppercase

$
0
0

Dears,

In my xamarin forms project button text are always show in uppercase format.
But I am providing upper and lower case letters in xaml. When I build the solution all the letters are changed to uppercase.

Any solution.
Thanks in advance.

How to display 360 video

$
0
0

I have a Xamarin.iOS app where video is displayed in a WKWebView.

360 panoramic videos don't display properly, which looks like its an inherent limitation in the web view.

Is there any way to

  1. Get the 360 video to display correctly in the WKWebView
  2. Read the video's metadata to determine if it is 360 so I can open it in something else?

Thanks

Setting BackButtonTitle with Prism ?

$
0
0

Hi,

i have a Xamarin.Forms app using Prism. The main page is a MasterdetailPage with few buttons that navigate to other pages ... (still hamburger menu on the navigation bar) but when i navigate from those pages (now i have a classic navigation bar instead of hamburger) .. lets say to some item detail page i want to have a custom text next to the backbutton arrow.

I tried setting NavigationPage.BackButtonTitle in xaml of the MainPage but it doesnt work ..
If i try to set HasBackButton="False" .. the back button is replaced by Hamburger(?).

How can i change the backbuttontitle from viewmodel ?
Or how can i hide the burger menu ? and use TitleView ...

Also i noticed if i change the BackButtonTitle in the MasterDetail detailpage it changes the backbutton title on the ItemDetailPage too ...

Thanks for any advice

iOS Simulator "Could not find sdk bin directory" error

$
0
0

While trying to run a project on the iOS simulator through Visual Studio on a pc and connecting to a Mac (utilizing Xcode), the error "Could not find sdk bin directory" comes up and stops building of the project on Visual Studio.

Does anyone has any experience with or fixes to this error?
Any information that could be provided on it would be greatly appreciated. Thanks!

is it possible for android not to enter the OnDestroy() method and keep the app ruining

$
0
0

Hello guys i'm using xamarin forms
i have a class LocalNotif wish content notification calls
on IOS devices i manage to fetch the device even when the app is destroyed but in Android i don't know how
can any one help please.
Thank you

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>