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

Android SetPage after async fails

$
0
0

I'm trying to navigate from a splash screen (ContentPage) to the main app screen (MasterDetailPage). In my ViewModel, I send a message to the native Android activity passing in the new MasterDetailPage. On the message handler, I just SetPage(message.NewPage) and everything works fine.

BUT...

If I send the message in an async method after a Task.Delay(2500), the message reaches the Activity code and the SetPage is executed, but the Android emulator only shows a blank screen =( No exceptions are thrown (at least the debugger didn't catch any).

Which is the best way to override the current Page (I don't need navigation here), after an async call?

Resume: Works: Method GoTo(new ContentPage()) => Sends a Message with ContentPage => The AndroidActivity listens to this message => SetPage(ContentPage) => Success \O/

Does not works: Method async Task.Delay(2500); GoTo(new ContentPage()) => everything is exactly the same after that => SetPage(ContentPage) => Blank screen =(

BTW... In Windows Phone, both sync/async methods works fine. Didn't had the time to test on iOS.

In Windows Phone, the code is:

    protected virtual void OnTopNavigationMessage(TopNavigationMessage message)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            var newContent = (FrameworkElement) message.View.XFormsPage.ConvertPageToUIElement(this);

            if (newContent.Parent != null)
            {
                ((Panel) newContent.Parent).Children.Remove(newContent);
            }

            Content = newContent;
        });
    }

In Android:

    protected virtual void OnTopNavigationMessage(TopNavigationMessage message)
    {
        Device.BeginInvokeOnMainThread(() => SetPage(message.View.XFormsPage));
    }

And in iOS:

    protected virtual void OnTopNavigationMessage(TopNavigationMessage message)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            window.RootViewController = message.View.XFormsPage.CreateViewController();
        });
    }

This works:

    protected override  void OnInitialize()
    {
        GoTo<HomeView>();
    }

    public void GoTo<TView>()
        where TView : BaseView
    {
        var view = BaseApp.BaseInstance.DependencyContainer.Resolve<TView>();

        MessengerInstance.Send(new TopNavigationMessage(view));
    }

But this doesn't:

    protected override async void OnInitialize()
    {
        await Task.Delay(2500);

        GoTo<HomeView>();
    }

    public void GoTo<TView>() (SAME CODE ABOVE)

UICollectionView ItemSelected fix coming?

$
0
0

Any news on when this UICollectionView ItemSelected big might be resolved? It's a gnarly one.

accessing one control of one page to another page

$
0
0

Hello,

I am working on xamarin forms since last month.But now I struck up with a problem. I created a ContentView that is to be used in a ContentPage and I am able to access the ContentView in any ContentPage I want to. But,now I want a control of one view to be used in another view or page.For example I want an Image of one View to be accessed in antoher view.

Thanks in advance.

Ads in Xamarin.Forms

$
0
0

Hello..!!!

I an working on Banner Ads in xamarin forms.Can anyone please help me out in this.

Fragment save state when orientation change without configchanges

$
0
0

How do i save the current fragment when the orientation changes? And how do i save the bundle.PutString that i put in the bundle arguments? when i navigate to the new fragment to retrieve it it works fine but when i rotate it, it returns the bundle as null.

Bundle data = new Bundle();
data.PutString("CategoryName", catname);
data.PutString("CategoryRange", catrange);
var frog = MainActivity.fs.CurrentFragState ("CategoryDetail");
frog.Arguments = data;
frog.RetainInstance = true;
transaction.Replace (Resource.Id.detailsContainer, frog);
transaction.AddToBackStack(null);
transaction.CommitAllowingStateLoss();
MainActivity.currentFrag = "CategoryDetail";

In the navigated Fragment's OnCreateView. i do this to retrieve the data but when i rotate it, bun becomes null and nothing works.

var bun = Arguments;
    if (bun != null)
    {
        categorySelected = bun.GetString ("CategoryName");
        categoryRangeSelected = bun.GetString ("CategoryRange");
    }

Please help! I couldnt find anything online and the Xamarin instructors aren't responding. Thank you!

Key issue when i was using Xamarin.Forms.

$
0
0
  1. MasterDetailPage was not working like a slidingmenu did in Android. it couldn't slide the actionbar. 2.Tabedpage looks diffirent on ios and android. I can't add image to tab header, also no badge supported. How does they works now in .Formx 1.3+?

Form design for Android in Xamarin Studio

$
0
0

Hello I hope to be in the right forum. I'm making my first steps to design a simple form for an Android device in Xamarin Studio Adding button, Textview, EditText is simple but but organize the layout and size attributes becomes a bit more tricky. I've a very good experience with Windows Form but I'm a total newbie with axml, xaml, etc.. Is there any good tutorial to learn axml form design ?

Thanks for any help

Memory Management

$
0
0

Hi!

I'm currently working on a project that contain a lot of images. All file are process by TexturePacker as .plist. CocosSharp load all files in memory and display the Scene 1 perfectly.

When I'm left this scene and load the Scene 2, I currently execute there 2 lines:

CCSpriteFrameCache.SharedSpriteFrameCache.RemoveUnusedSpriteFrames ();

CCTextureCache.SharedTextureCache.RemoveUnusedTextures ();

And If I check the count of the dictionary, all textures are well unload and that good!

The problem begin here, I receive a lot of memory warning and the application crash with i'm switch from scene 1 to 2 back to 1 and back to 2! If I load instruments, I can see the memory usage growing about 20 MO per scene change but that all the same images and sprites!! Someone have a hint ?

Sorry for my english, I speak french and I do my best :)

Simon


Embedding Youtube in WebView

$
0
0

I'm trying to embed a youtube video into a WebView but when I load the Url it shows me "Blocked Plug-in". Can anyone please tell me how to play youtube Video in Webview?

Zxing not working on iOS 8

$
0
0

HI I am was using zing for bar code scanner. Before upgrade to iOS 8.0, it was working fine. But after update its throwing below error though I am using a actual device.

Starting to scan... StartScanning No input - this won't work on the simulator, try a physical device Capture Session FAILED

Same code has been used. I tried using latest version of zing but no luck. Does any body faced same problem?

Thanks in advance.

How to hide keyboard when clicking anywhere but him?

$
0
0

Just that is there a simple call?

Android Player Displays OpenGL Error

$
0
0

Using Xamarin Android Player version 0.0.25 on MacBook Pro running OS X 10.9.5.

Running either one of the currently available Nexus virtual machines displays the following error in a popup window:

"OpenGL server is unreachable. Please check that Xamarin Android Player is allowed through your firewall on public networks."

Clicking the OK button on the popup will hide the Android Player virtual machine window, but the virtual machine itself will continue to run in the background until I click the Stop button on the Devices list.

The OS X firewall is turned off.

When watching the preview window in VirtualBox 4.3 the virtual machine continues to boot and eventually will display the Android home screen within the VirtualBox preview window.

I have tried uninstalling both the Android Player and VirtualBox, but am still encountering the same problem.

Is there anything else I should try?

ReloadRows animation has different durations

$
0
0

I'n trying to reload the size of one particular row in a UITableView.

First time I update the row is when the row is selected

public override void RowSelected (UITableView tableView, NSIndexPath indexPath) { tableView.BeginUpdates (); tableView.ReloadRows (new []{indexPath}, UITableViewRowAnimation.Automatic); tableView.EndUpdates (); }

The row is nicely animated 150f bigger or smaller.

Inside the row there is a DateTimePicker and when the ValueChanged event is fired I want to resize the tablecell to the 'normal' size.

Inside my datasource is an eventhandler like below: void HandleValueChanged (object sender, QuestionChangedEventArgs e) { InvokeOnMainThread (() => { _tableView.BeginUpdates (); _tableView.ReloadRows (_tableView.IndexPathsForVisibleRows, UITableViewRowAnimation.Automatic); _tableView.EndUpdates (); }); }

When the ReloadRows is fired from the eventhandler the animation is taking a very short duration. Updated the animation to Left, and i see the animation but's way faster than via the rowselected event.

Tried it with/without the InvokeOnMainThread fuction, but no luck.

Any ideas why this behaviour is happening?

How to implement Auth0 in xamarin.forms

$
0
0

Hello All, I am a student from the india and i want to learn about the xamarin so i have to created a application in which, i want implement Auth0 with the xamarin.forms in mvvm if any support person have the knowledge about that so please suggest me what i have to do for that . i have tried to search in google but not getting any luck. so please please help me.

Reading a text file

$
0
0
using System;
using System.IO;
using System.Collections;
using Android.App;
using Android.Content.Res;

namespace TestSpace
{
public class Dictionary : Activity
{
    //the arraylist that all the words will be loaded into
    private ArrayList dictionary;

    /// <summary>
    /// Uses a stream to get all the words out of the dictionary text file
    /// and load them into memory, so that they can be searched
    /// </summary>
    /// <returns>True if successful, false if the dictionary couldn't be opened</returns>
    public bool Initialize()
    {
        dictionary = new ArrayList();
        try
        {
            using (StreamReader sr = new StreamReader(Assets.Open("Dictionary.txt")))
            {
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    dictionary.Add(line);
                }
            }
        }
        catch (Exception e)
        {
            return false;
        }
        return true;
    }

    /// <summary>
    /// Use binary search to detect whether or not
    /// the input string exists in the dictionary
    /// </summary>
    /// <param name="find">The string to compare</param>
    /// <returns>Whether or not the input string is a real word</returns>
    public bool search(string find) {
        find = find.ToLower();
        if (dictionary.BinarySearch(find) >= 0)
        {
            return true;
        }
        return false;
    }
}
}

The file reading part is nearly identical to Xamarin tutorials, and I've put Dictionary.txt in the Assets folder with build action>AndroidAsset and yet it throws an exception. Can anyone find out why?

{Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 at Android.Runtime.JNIEnv.CallNonvirtualObjectMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:526 at Android.Content.ContextWrapper.get_Assets () [0x0005a] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.Content.ContextWrapper.cs:141 at DrawingTest.Dictionary.Initialize () [0x0000d] in c:\Users\Corey\Documents\Projects\DrawingTest\DrawingTest\Dictionary.cs:25 --- End of managed exception stack trace --- java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.content.Context.getAssets()' on a null object reference at android.content.ContextWrapper.getAssets(ContextWrapper.java:79) at drawingtest.MainActivity.n_onCreate(Native Method) at drawingtest.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:5933) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) } Java.Lang.NullPointerException


Swipe Gestures using Xamarin.Forms inside a layout

$
0
0

Hi All,

Can anyone help me out for implementing swipe gesture for stack layout using Xamarin.Forms...

Swipe Gesture Using Xamarin.Forms

$
0
0

Hi All,

Can anyone help me out in implementing swipe gesture for stack layout using Xamarin.Forms... I want to change the content inside a stack layout with swipe(Right & Left)..Can this be achieved without using custom rendering..?

MonoTouch.Dialog and Unified API

$
0
0

I'm looking at upgrading my project to the Unified API and am wondering what to do about MonoTouch.Dialog. Are there any plans to port it to Unified?

Xamarin Android Player

$
0
0

Can I use Xamarin Android Player inside a Virtual machine?

Upgraded to Forms 1.3 pre 1 and get a "Not registered task XamlG" build error for my android proj?

$
0
0

The output from the build is the following:

Target GenerateXamlG: Task "XamlG"
error : Error initializing task XamlG: Not registered task XamlG. Error initializing task XamlG: System.Exception: Not registered task XamlG. at Microsoft.Build.BuildEngine.TaskDatabase.ThrowTaskNotRegistered (System.String classname) [0x00000] in :0 at Microsoft.Build.BuildEngine.TaskDatabase.GetTypeFromClassName (System.String classname) [0x00000] in :0 at Microsoft.Build.BuildEngine.BuildTask.get_Type () [0x00000] in :0 at Microsoft.Build.BuildEngine.BuildTask.InitializeTask () [0x00000] in :0 at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x00000] in :0

All I have done is reference the new nuget and updated and changed the custom build tool for all of the .xaml files.

Anyone else come across this?

Viewing all 204402 articles
Browse latest View live




Latest Images