Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

Getting error Activity has been destroyed


How to align left a navigation bar Title in iOS using Xamarin forms

$
0
0

Hello, is there a way to align left the title of a navigation bar of a page when using MasterDetailPage? By default it seems to be centered in iOS
But I want it to be left-align as in android.
Thank you all.
here is what i have now
image

And here is what I want:
image

Debugger can't launch iOS app on the iPhone device

$
0
0

Visual Studio starts running the debugger, but this is the error I'm getting in the console:

Launching 'App26iOS' on 'x's iPhone'...
Launch failed. The app 'App26iOS' could not be launched on 'x's iPhone'. Please check the logs for more details.

The app doesn't start running on the iPhone. If I tap on the app icon, then VS debugger will continue and write a bunch of stuff to the console.

When the error says to check the logs, where do I look for the logs? Where are they located?

This started happening after I updated to 2.2.0.23-pre4.

iOS debug deployment failing

$
0
0

I'm seeing an error after I try deploying my iOS build to a simulator on my mac machine (via Xamarin Mac Agent) which I remote in to

It built, deployed, executed, and the debugger attached successfully.
I terminated it.
The next time and all subsequent attempts, I get the following error. The app does not get deployed (it is not present on the simular)

Launching 'App.iOS' on 'iPhone 6 iOS 10.2'...
Launch failed. The app 'App.iOS' could not be launched on 'iPhone 6 iOS 10.2'. Error: The post for client vs4064jwier on topic xvs/idb/4.2.1.64/launch-app has been cancelled. Please check the logs for more details.
The app has been terminated.

Toolbar manipulation

$
0
0

I'd like to do the following with a Xamarin.Forms toolbar:

  • Set the color

  • Center the title

  • Put buttons to the left of the title

Is this possible with or without customization?

Thanks

Android deployment failing

$
0
0

I can't determine why my android project is crashing immediately after lauching after the app is deployed to my emulator.
It was working fine and then it wasn't. There was no change I made in between which is all the more confusing.

Here is the device log output for Errors ( I can include the verbose version as well if that is more helpful but it is large).

I put this in the android forum but realized it might be more applicable to the xamarin forms forum.

Time    Device Name Type    PID Tag Message
01-10 08:38:44.593   5" KitKat (4.4) XXHDPI Phone   Error   1966    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:44.593   5" KitKat (4.4) XXHDPI Phone   Error   1966    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:44.565   5" KitKat (4.4) XXHDPI Phone   Error   1966    cutils-trace    Error opening trace file: No such file or directory (2)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:5001)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime  Caused by: java.lang.ClassNotFoundException: Didn't find class "md5ca27074e405277e6c40e6a6588077a84.MainApplication" on path: DexPathList[[zip file "/data/app/com.cii.patrollive-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.cii.patrollive-1, /system/lib]]
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.os.Looper.loop(Looper.java:136)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      ... 11 more
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.ActivityThread.access$1500(ActivityThread.java:135)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at java.lang.reflect.Method.invoke(Method.java:515)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:102)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.Instrumentation.newApplication(Instrumentation.java:975)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime  Process: com.cii.patrollive, PID: 1948
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime  java.lang.RuntimeException: Unable to instantiate application md5ca27074e405277e6c40e6a6588077a84.MainApplication: java.lang.ClassNotFoundException: Didn't find class "md5ca27074e405277e6c40e6a6588077a84.MainApplication" on path: DexPathList[[zip file "/data/app/com.cii.patrollive-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.cii.patrollive-1, /system/lib]]
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at java.lang.reflect.Method.invokeNative(Native Method)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime  FATAL EXCEPTION: main
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at dalvik.system.NativeStart.main(Native Method)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
01-10 08:38:39.201   5" KitKat (4.4) XXHDPI Phone   Error   1948    AndroidRuntime      at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
01-10 08:38:38.917   5" KitKat (4.4) XXHDPI Phone   Error   1938    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:38.917   5" KitKat (4.4) XXHDPI Phone   Error   1938    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:38.845   5" KitKat (4.4) XXHDPI Phone   Error   1938    cutils-trace    Error opening trace file: No such file or directory (2)
01-10 08:38:38.541   5" KitKat (4.4) XXHDPI Phone   Error   1926    cutils-trace    Error opening trace file: No such file or directory (2)
01-10 08:38:38.469   5" KitKat (4.4) XXHDPI Phone   Error   1926    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:38.469   5" KitKat (4.4) XXHDPI Phone   Error   1926    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:34.757   5" KitKat (4.4) XXHDPI Phone   Error   1896    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:34.757   5" KitKat (4.4) XXHDPI Phone   Error   1896    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:34.729   5" KitKat (4.4) XXHDPI Phone   Error   1896    cutils-trace    Error opening trace file: No such file or directory (2)
01-10 08:38:34.445   5" KitKat (4.4) XXHDPI Phone   Error   1880    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:34.445   5" KitKat (4.4) XXHDPI Phone   Error   1880    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:34.421   5" KitKat (4.4) XXHDPI Phone   Error   1880    cutils-trace    Error opening trace file: No such file or directory (2)
01-10 08:38:34.145   5" KitKat (4.4) XXHDPI Phone   Error   1866    android.os.Debug    failed to load memtrack module: -2
01-10 08:38:34.145   5" KitKat (4.4) XXHDPI Phone   Error   1866    memtrack    Couldn't load memtrack module (No such file or directory)
01-10 08:38:34.113   5" KitKat (4.4) XXHDPI Phone   Error   1866    cutils-trace    Error opening trace file: No such file or directory (2)

Login persistance with Akavache

$
0
0

Hi All,

I'm trying to implement login persistance feature in my app with Akavache but so far without success.
I want to have it because I don't want user to login in every single time he starts an application.

So in my SignInViewModel I am doing smth like this:

`User u = await _userRepository.SignIn(uDTO);

            if(u != null)
            {
                await BlobCache.UserAccount.InsertObject("User", u);

                MessagingCenter.Send<User>(u, "Authorized");
            }`

This is working OK the object is saved but in my Application based class I am doing smth like this:

`protected override void OnStart ()
    {
        base.OnStart ();

        BlobCache.UserAccount.GetObject<User>("User")
                .Subscribe(x => _u = x, ex => Console.WriteLine("No Key!"));

        if (_u != null)
        {
            MessagingCenter.Send<User>(_u, "Authorized");
        }
    }`

I don't know how to test it on emulator, so I decided to test it on Android device, but after sign in, close and start the application I am not signed in.
What am I doing wrong? How to debug this (when I close the app the debugger close too)
thx

Did something change from 2.3.1.114 to 2.3.3.180 with regard to Android fonts?

$
0
0

I have just upgraded to 2.3.3.180, and started to get crashes everywhere on Android regarding Custom Fonts.

Specifically, in our CustomLabelRenderer base.OnElementChanged call, we are seeing an unhandled exception "Java.Lang.RuntimeException: Font asset not found {fontname}".

I have found that if I strip the font name right back to its basic name (i.e. fontawesome.ttf instead of \assets\fonts\fontawesome.ttf) then the crash goes away, but this means a huge refactoring going back through thousands of lines of XAML to amend every font (for Android only).

It seems that suddenly Xamarin are trying to load the font for us instead of having to have a custom renderer, but it doesnt like the path names.

I changed the font names on a few pages to see if this actually worked now, and while the error goes away, the font doesnt actually get used, so im not sure what is trying to be achieved here...

Anyone else come across this?


How to print image via bluetooth printer

$
0
0

Hello , everyone, Currently i am develop a program that allow user to print receipt .Now i want to enhance it so it can print image (Company Logo) , so anyone know how to print image from xamarin form? Any sample?

How to set the background-image style property to a png file

$
0
0

Hi
I have an application in Xamarin Forms. I am using the hybridwebview component to render an HTML which has a 3rd party (kendo) style sheet reference. I have an issue where the kendo references (through class definition) a png file which is located in a folder. I can override this class style and set the background-image to point to whichever location I want. However I cannot get this working which off course means I am not doing it correctly.

Here is the style they have got
.k-icon,
.k-tool-icon,
.k-grouping-dropclue,
.k-drop-hint,
.k-column-menu .k-sprite,
.k-grid-mobile .k-resize-handle-inner:before,
.k-grid-mobile .k-resize-handle-inner:after,
.k-pager-numbers .k-current-page .k-link:after,
.k-scheduler-toolbar > ul.k-scheduler-views > li.k-current-view > .k-link:after,
.k-gantt-views > .k-current-view > .k-link:after {
background-image: url('Default/sprite.png');
border-color: transparent;
}

I can override the background-image property for .k-icon and set to a different local location. Can someone please show how I can set this.

Is this possible? Fetching images from ios album as UI image.

$
0
0

I worked on Android, which is very easy. Add file path for images, and if images not there, it won't error, and it will display icons etc when images are there.

However, in iOS seems to be a completely different story.

I found a couple of examples on line, but all seems too old, still using ALAsset which is obsolete.

Is there any updated examples of this?

how iOS handle when the images not there?

Can iOS locate images to load by "file name"? for example, app only knows file name, not file location or id. After user copied images with certain filenames into album, app will automatically pick them up.

Thanks in advance.

How can I add a ToolbarItem to a non-root Navigation Page in Xamarin.Forms?

$
0
0

Hi!

On App.xaml.cs, I call the main page using:

MainPage = new NavigationPage(new MainPage());

On MainPage.xaml, the ToolbarItems is working as expected, using the following code:

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Menu1" Order="Secondary" />
    <ToolbarItem Name="Menu2" Order="Secondary" />
    <ToolbarItem Name="Menu3" Order="Secondary" />
    <ToolbarItem Name="Menu4" Order="Secondary" />
</ContentPage.ToolbarItems>

When I call another page from MainPage.xaml.cs using the following code:

await Navigation.PushAsync(new ManageServices());

and add the following code to ManageServices.xaml, the ToolbarItems does not appear.

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Menu1" Order="Secondary" />
    <ToolbarItem Name="Menu2" Order="Secondary" />
    <ToolbarItem Name="Menu3" Order="Secondary" />
    <ToolbarItem Name="Menu4" Order="Secondary" />
</ContentPage.ToolbarItems>

I need to maintain the navigation stack (MainPage > ManageServices) so the user can navigate back from ManageServices to MainPage, and at the same time, have a different context menu in ManageServices using ToolbarItem.

How can I do that?

Thank you!

Navigation Stack Android Problem

$
0
0

Hi, i have same issues with the navigation stack because if navigate to more than two page in third page the GUI not update. For example a Editor not update its content while i write, but if i check if there was a content in it than i wrote, code result true. Or the webview content not update. If i use PopModalAsync it work correctly but with PopAsync no. What is the problem?

Thanks

Creating a Custom ViewRenderer As a Pass Through To Native Control

$
0
0

Hello,

I have native controls for iOS and Android that contain state and have methods. I would like to create a Xamarin.Forms View wrapper around these controls using a custom ViewRenderer. I would like to keep as much state in the native controls as possible, and simply use the XF View and ViewRenderer as a pass-through for method calls and fields.

The issue I have is that when a View is instantiated, a matching ViewRenderer is not created until the View is added to the UI tree. So this code works:

MyClassView v = new MyClassView();
myGrid.Children.Add(v); // renderer gets created behind the scenes here
v.DoAction1();

But not this code:

MyClassView v = new MyClassView();
v.DoAction1(); // no renderer yet, throws NullReferenceException
myGrid.Children.Add(v);

Here is the v1 implementation that exposes this problem:

namespace MyCustomNamespace
{
    public class MyClassView : View, IDisposable
    {
        private IMyClassRenderer renderer;

        public void DoAction1()
        {
            renderer.DoAction1();
        }

        internal void SetMyClassRenderer(IMyClassRenderer myClassRenderer)
        {
            this.renderer = myClassRenderer;
        }

        internal void TriggerLoadingStatusChanged(LoadingStatusChangedEventArgs e)
        {
            UpdateSomething();
        }
    }
}

using Internal = Com.My.Java.Namespace;
[assembly: ExportRenderer(typeof(MyClassView), typeof(Android.MyClassRenderer))]
namespace MyCustomNamespace.Android
{
    public class MyClassRenderer : ViewRenderer<MyClassView, Internal.MyClass>, IMyClassRenderer
    {
        public void DoAction1()
        {
            Control.DoAction1();
        }

        protected override void OnElementChanged(ElementChangedEventArgs<MyClass> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                SetNativeControl(new Internal.MyClass(Context));
                Element.SetMyClassRenderer(this);
            }

            if (e.OldElement != null)
            {
                Control.LoadingStatusChanged -= this.Control_LoadingStatusChanged;
            }

            if (e.NewElement != null)
            {
                Control.LoadingStatusChanged += this.Control_LoadingStatusChanged;
            }
        }

        private void Control_LoadingStatusChanged(object sender, Internal.LoadingStatusChangedEventArgs args)
        {
            Element.TriggerLoadingStatusChanged(new LoadingStatusChangedEventArgs(args.Status));
        }
    }
}

public IMyClassRenderer
{
    void DoAction1();
}

// JAVA CONTROL
public class MyClass extends FrameLayout
{
}

The solution I came up with is to create and set a renderer when in my View's constructor. This works, but gets messy when my View is added to the UI tree, and Xamarin creates another renderer. To preserve the state of my native control, I then grab the native control from the first renderer and give it to the second renderer, and have the first renderer unsubscribe to events form my native control.

Here is the v2 code for this solution:

namespace MyCustomNamespace
{
    public class MyClassView : View, IDisposable
    {
        private IMyClassRenderer renderer;

        internal object NativeControl;

        public MyClassView()
        {
            this.renderer = DependencyService.Get<IRendererHelper>().CreateAndSetRenderer(this);
        }

        public void DoAction1()
        {
            renderer.DoAction1();
        }

        internal void SetMyClassRenderer(IMyClassRenderer myClassRenderer)
        {
            if (this.renderer != null)
            {
                this.renderer.UnhookEvents();
            }

            this.renderer = myClassRenderer;
        }

        internal void TriggerLoadingStatusChanged(LoadingStatusChangedEventArgs e)
        {
            UpdateSomething();
        }
    }
}

using Internal = Com.My.Java.Namespace;
[assembly: ExportRenderer(typeof(MyClass), typeof(MyClassRenderer))]
namespace MyCustomNamespace.Android
{
    public class MyClassRenderer : ViewRenderer<MyClass, Internal.MyClass>, IMyClassRenderer
    {
        public void DoAction1()
        {
            Control.DoAction1();
        }

        protected override void OnElementChanged(ElementChangedEventArgs<MyClass> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                if (Element.NativeControl == null)
                {
                    SetNativeControl(new Internal.MyClass(Context));
                    Element.SetMyClassRenderer(this);
                    Element.NativeControl = this.Control;
                }
                else
                {
                    Internal.MyClass internalMyClass = Element.NativeControl as Internal.MyClass;
                    ((MyClassRenderer)internalMyClass.Parent).RemoveView(internalMyClass);
                    SetNativeControl((Internal.MyClass)Element.NativeControl);
                    Element.SetMyClassRenderer(this);
                }
            }

            if (e.OldElement != null)
            {
                Control.LoadingStatusChanged -= this.Control_LoadingStatusChanged;
            }

            if (e.NewElement != null)
            {
                Control.LoadingStatusChanged += this.Control_LoadingStatusChanged;
            }
        }

        private void Control_LoadingStatusChanged(object sender, Internal.LoadingStatusChangedEventArgs args)
        {
            Element.TriggerLoadingStatusChanged(new LoadingStatusChangedEventArgs(args.Status));
        }

        public void UnhookEvents()
        {
            Control.LoadingStatusChanged -= this.Control_LoadingStatusChanged;
        }
    }
}

[assembly: Xamarin.Forms.Dependency (typeof (RendererHelperImplementation))]
namespace MyCustomNamespace.Android
{
    internal class RendererHelperImplementation : IRendererHelper
    {
        public IMyClassRenderer CreateAndSetRenderer(View view)
        {
            var renderer = Platform.CreateRenderer(view);
            Platform.SetRenderer(view, renderer);

            return (IMyClassRenderer)renderer;
        }
    }
}

This seems to work, but boy oh boy does it feel inelegant. I also fear that some of the View <-> Renderer mapping that Xamarin normally takes care of will be incorrect due to my mucking around.

Does anyone know of a better solution to this problem?

Thanks,
Wyatt

How to debug javascript with hybridwebview

$
0
0

Hi
We are developing with Xamarin Forms and I am using HybridWebView component. Can anybody tell me how I can debug my javascript code with the webview.


Startup Times

$
0
0

Ok, I have a wild one... I've got two handy test devices. An iPhone5 and an iPhone6. I loaded up the iPhone5 and gave it to my boss to play with. It loads just fine and is working no problem. I then went to work fixing the splash screen, and tweaking the icon, then tried to load it on my iPhone6. ... which of course wasn't in my provisioning profile.

After fixing that and recompiling, my app either takes well over a minute to load, OR it shows the splash screen for a minute and crashes. The previous build comes right up on the older phone. I've tried tweaking many settings, release vs. debug builds, LLVM compiler, etc, to no avail. I have two clues so far:

  1. It seems to NOT crash when I use the debugger to launch the app. It crashes most (but not all) of the time when I touch the icon on the phone screen.
  2. If I change from "Link Framework SDKs only" to "Link All", it always crashes.

Anyone have any ideas of what to look for/try?

Thanks so much for any help you can give!
-Karen

Display Back Button In UWP App

$
0
0

My app has no back button. How do I just turn on the button so it's always there?

[TabbedPage] How to hide android TabBar

$
0
0

Hi all, I am using the TabbedPage in Forms and it appears at bottom in iOS and at top in Android. I want to hide the tabBar in Android after push to next page. How could you do that? I know Forms might not have the hidden API, but how would you do it in renderer or other places?

Thx in advance.

How to clear an image from cache?

$
0
0

I have several images of people and am giving them the ability to change the picture out by taking a new picture with their device. The images are stored on the web and the UriImageSource Uri is an internet url. Everything works perfectly until the image changes on the server, I can't figure out how to invalidate the cache and re-load the image from the server. I have tried appending a querystring on the end of the file (i.e. https://www.image.com/Image.jpg?ver=33), tried creating a new UriImageSource with caching enabled = false, but nothing seems to work...?

I have tried using regular images as well as James' ImageCircle plugin.

Playing sounds with Xamarin.Forms

$
0
0

Hi!

I am studying Xamarin, and, as a practice, trying to make a stopwatch which ticks every second, but I didn't found any informatin about working with sounds on forums. Where to find this information?

With best regards!

Viewing all 91519 articles
Browse latest View live


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