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

Didn't find class for create countdown timer

$
0
0

Hello, I'm new with Xamarin. I need some help here, I tried to create a countdown timer. I already done that following some tutorial but there is a problem when i try to start the countdown
this is my error :

Unhandled Exception:

Java.Lang.ClassNotFoundException: Didn't find class "md5579855c995bdb073d8182511e793544c.MainActivity_CountDown" on path: DexPathList[[zip file "/data/app/App1.App1-1/base.apk"],nativeLibraryDirectories=[/data/app/App1.App1-1/lib/arm64, /data/app/App1.App1-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]

and this is my code :
private class CountDown : CountDownTimer
{
Context mContext = Application.Context;
MainActivity activity;

        public CountDown(MainActivity activity, long totalTime, long interval) : base(totalTime, interval)
        {
            this.activity = activity;
        }

        public override void OnFinish()
        {

        }

        public override void OnTick(long millisUntilFinished)
        {
            SharedPref sharedPref = new SharedPref(mContext);
            long defaultTimer = sharedPref.GetTimer();
            long milliseconds = defaultTimer / 1000;
            long minutes = (long)(millisUntilFinished / (1000 * 60) % 60);
            long seconds = (long)(millisUntilFinished / (1000) % 60);

            activity.textViewTimer.Text = string.Format("{1:00}:{2:00}", minutes, seconds);
        }
    }

private void StartTimer()
    {
        SharedPref sharedPref = new SharedPref(mContext);
        long defaultTimer = sharedPref.GetTimer();
        CountDown count = new CountDown(this, defaultTimer, 1000);
        count.Start();
    }

I got the error in here :
base(totalTime, interval)

I really appreciate if you guys can help me. Thank you.


Xamarin Forms Visual Studio 15.5 and Images

$
0
0

Newbie looking for a simple step by step example of the correct method for getting an image to show up in Xamarin forms for ios and Visual Studio 15.5.

This project type requires Xamarin.Android to be installed help!

$
0
0

After updating, this error appeared

This project type requires Xamarin.Android to be installed help!

How to enable word wrap in Text Editor?

CGImage.ScreenImage(id,rect); is returning a 1x1 image

$
0
0

Hi there,

I'm trying to capture the screen into a CGImage object.
The code I'm converting originally called

cgImage = CGDisplayCreateImage(_displayId);

I don't see a direct replacement for that in Xamarin, so instead I'm trying:

CGRect rect = CGDisplay.GetBounds(_displayId);
cgImage = CGImage.ScreenImage(_displayId, rect);

I assume the _displayId is correct because I get a rect back 1680x1050
It's retrieved using

CGRect rect = CGDisplay.GetBounds(_displayId);

Is there some initializer call I'm missing? Or some alternative call I can make to get a CGImage back of the screen?

Alternatively, can anyone show me what the signature would look like to DllImport this one?

CG_EXTERN CGImageRef __nullable CGDisplayCreateImage(CGDirectDisplayID displayID)?

Switch with IsToggled binding is throwing Toggled event on init when bound value is true

$
0
0

I have the following XAML:

<Switch
       IsToggled="{Binding IsChecked}"
       IsEnabled="true"
       Toggled="MyToggledEventHandler"
       VerticalOptions="CenterAndExpand"
       HorizontalOptions="EndAndExpand" />

This switch exists as part of a custom listview viewcell template, and the records that supply the listview elements are loaded asynchronously as part of the ContentPage's OnAppearing() method. The ListView is hidden until these records have been loaded, as part of some MultiTriggers I have setup on the ListView to determine its IsVisible property. When the records get set into the BindableProperty to feed the listview, MyToggledEventHandler gets called for each record where IsChecked is true. This is not desirable because I have a server-side HTTP call that takes place as part of that event handler. How can I avoid this event being thrown while still taking advantage of XAML-only binding?

I should point out that I am not programmatically changing the IsChecked property at any point - it is true/false at the point that it gets set into the ListView ItemsSource property.

EDIT:
At the moment I am able to get around this with a secondary "checked" property in the record that is not a BindableProperty - when it doesn't match the bound property, then I know it was hand-toggled; when they do match, it's on init. I can use that trick to return early from MyToggledEventHandler. Definitely a hack, but it'll work until I get a better response.

Clear Navigation Stack on iOS

$
0
0

Hello Everyone, i hope i can get some help here. I've been going crazy for weeks now!

I have an app functionning perfectly, but the only clue right now is i wish to clear the navigation stack, each time i reach a specific view controler.

say i have 5 views A;B;C;D;E, and during navigation i move from A->B->C->D->E, now i have a button which can bring me back to controler A, but now, when i press back icon on navigation bar, i wish to close the application (not go back to view controler E->D->C->B->A).

Please is there anyway to to this on Xamarin C#?

Any help shall be greatly appreciated. Thanks !!

How to publish multiple apks per selected ABI on google playstore?

$
0
0

I have asked this question on SO long time ago but I didnt get answer. I would like to ask it again.
It is advised to use this option "Generate one package(.apk) per selected ABI" in order to reduce App size but what can I do with those single apk's? how can upload them to Google playstore? I can only upload 1 apk as far as I know. what is the proper way?


Xamarin forms upgrade

$
0
0

I upgraded xamarin forms to 2.5.0.121934 and after this I am getting an error like this.
Severity Code Description Project File Line Suppression State
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Fragment.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute()

Please help

iOS Launch Images not showing up

$
0
0

I hate to ask a question that I know there must be an easy answer to, but for the life of me I can't get iOS to launch with the right launch images!

I have edited the iOS settings, and moved the assets to Asset Catalogues. Then opened up that Contents.json and added images for each box. No cigar. Everytime I launch, I get a blue background with my app icon centered in the middle.

Thanks in advance for any help.

EditText field change size?

$
0
0

Hello Guys,

how I can change a size of an EditText field in my Main.xaml file?

I use Visual Studio and use the designer or source file. If I set a max and min height/width nothing change.

Cheers

testing..

From Object to Byte Array in Xamarin Forms

$
0
0
Ho community!
I try to use
Serialize.Formatters.Binary.BinaryFormatter

With this class I can convert an Object (like JObject) to a Byte Array. I install it with nuget for Android, iOs and UWP but compiler say me that IT'S NOT INSTALLED FOR UWP

Anyone using Cloud Firestore yet ?

$
0
0

The title says it all, I see examples for Android and iOS with native tools but nothing so far for Xamarin.
Thanks in advance for any information you have to share.

How to communicate between Android devices without the presence of router and dedicated server

$
0
0

For a gaming product results have to be exchanged frequently between Android devices without access to a server using a router or other access point to the internet. The number of devices can be unlimited, but usually no more than 10. I have done this with Wifi-Direct and tcp for 2 devices. With more tablets it is possible with one device as group owner (GO) and others as client. It does not seem to be very robust and poses problems when the GO fails. Bluetooth is perhaps also an option (the devices should also be in each others proximity, but the reach is less than with Wifi). So does anyone has experience with this? Is there perhaps a library for this type of networking? Or is there a reference somewhere that can help me?

Any help welcome.


PropertyChanged on a custom control not firing when using a {Binding}

$
0
0

Hello,

I have created a custom control with the following code:

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ControlLabel : ContentView
    {
        public string TitleText { get; set; }
        public string DescriptionText { get; set; }

        public static readonly BindableProperty TitleTextProperty =
            BindableProperty.Create("TitleText", typeof(string), typeof(ControlLabel), "", BindingMode.TwoWay, propertyChanged: TitleTextChanged);

        public static readonly BindableProperty DescriptionTextProperty =
            BindableProperty.Create("DescriptionText", typeof(string), typeof(ControlLabel), "", BindingMode.TwoWay, propertyChanged: DescriptionTextChanged);


        public ControlLabel()
        {
            InitializeComponent();
        }

        private static void TitleTextChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var control = (ControlLabel)bindable;
            control.Title.Text = newValue.ToString();
        }

        private static void DescriptionTextChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var control = (ControlLabel)bindable;
            control.Description.Text = newValue.ToString();
        }


    }
#
<?xml version="1.0" encoding="UTF-8"?>
<ContentView /*namespaces removed since the forum won't let me post them*/>
  <ContentView.Content>
      <StackLayout Spacing="0">
            <Label x:Name="Title" Style="{DynamicResource ListItemTextStyle}"/>
            <Label x:Name="Description" FontAttributes="Italic" TextColor="Gray" Style="{DynamicResource CaptionStyle}"/>
        </StackLayout>
  </ContentView.Content>
</ContentView>

I then use it like this:

<myApp:ControlLabel Grid.Row="0" Grid.Column="0" x:Name="WelcomeDesc" TitleText="test" DescriptionText="test123 456"/>

This works perfectly.

But then I try to replace the hardcoded text with a binding:

<myApp:ControlLabel Grid.Row="0" Grid.Column="0" x:Name="WelcomeDesc" TitleText="{i18N:Translate TransText}" DescriptionText="{i18N:Translate TransText1}"/>

When I run the app, then then both TitleText and DescriptionText are empty. But I know the binding is fine since built-in controls work just fine, this works no problem:

<Button Text="{i18N:Translate TransText}">

After some debugging, I found out that when I use the binding then the propertyChanged (TitleTextChanged) never fires, but with a hardcoded text it fires just fine.

What could be the problem? Thank you.

How to inspect incoming data from a SignalR connection?

$
0
0

I am creating a chat app and when I send a message it calls an event to send it to all clients, a broadcast. But I don't want to display the message back to the client that originally sent it. I cant think of an elegant way of doing it. All the ways I thought of it are bulky and stupid. Every message has a bool, Incoming. I am using Azure to host the SignalR hub.

Right now I have this to add the incoming messages to the ObservableCollection, "Messages"
_chatService.OnMessageReceived += (sender, message) => Messages.Add(message);

I wanted to assign a random ID number to each message getting sent. And if the message incoming has a matching ID# then I don't display it. But the only way I thought of being able to do that is to store the message in a temp ObservableCollection. then check the most recent addition and check its ID. But that seems really inefficient/stupid...

Also I thought of no displaying the message locally and only display it when it comes back from the server. But this has the same problem. Every message coming from the server would have the Incoming bool equal True.

Also I am only broadcasting to all clients because that is more simple and they way the tutorial I followed did it. Maybe this can all be fixed by only sending messages from the 1 person that is part of the chat (or all the people from a group chat)

Thanks

Updating a listView on itemSource change

$
0
0

Hi I'm pretty new in the Xamarin Forms world and I'm trying to have the listView that I created refresh its content when the itemSource change. Right know I have this:

public NearMe ()
        {
            list=jM.ReadData ();
            listView.ItemsSource = list;
            listView.ItemTemplate = new DataTemplate(typeof(FilialeCell));
            searchBar = new SearchBar {
                Placeholder="Search"
            };
            searchBar.PropertyChanged += (sender, e) => {
                TextChanged(searchBar.Text);
            };
            var stack = new StackLayout { Spacing = 0 };
            stack.Children.Add (searchBar);
            stack.Children.Add (listView);
            Content = stack;
        }
public void TextChanged(String text){
            if (!String.IsNullOrEmpty (text))
                text = text[0].ToString().ToUpper() + text.Substring(1);
            var filterSedi = list.Where (filiale => filiale.nome.Contains(text));
            List<Filiale> newList = filterSedi.ToList ();
            newList = newList.OrderBy (x => x.distanza).ToList();
            listView.ItemSource = newList;
        }

But this is not working, it gives me a blank page at startup, there is no searchBar and neither the listView element. I think that I can't simply assign a new itemSource is this correct? How can I implement this feature? Thank you for your help in advance.

download video from youtube and convert to mp3 with xamarin.forms

$
0
0

how can i do to download video from youtube and convert to mp3 with xamarin.forms?

How can I convert the video files into audio files in Xamarin.Forms?

Azure search is not working with typeahead functionality.

$
0
0

Hello guys, I have implemented azure search for searching workspaces from database which I have imported in azure. The issue is when I give a request call for searching the results, it has some time delay into it. My requirement is that I need a flawless azure search without hanging user for every work he types in the Entry field.

private async void SearchEntryTextChanged(object sender, TextChangedEventArgs e)
{
var entry = sender as CustomEntry;
string searchedString = entry.Text;
if (searchedString.Length > 2)
{
_workspaceSearchService = new AzureWorkspaceSearchApi();
List workspaceSearchData = new List();
//workspaceSearchData = await _workspaceSearchService.SearchWorkspaceFromAzure(searchedString);
workspaceSearchData = await _workspaceSearchService.ExecSuggest(searchedString);

               viewModel.SearchWorkspaceRecord = workspaceSearchData;
           }

}

For every character that enter after 2 length I am calling azure search. This request needs some time to get completed and hangs the user until it gets search result. I need these request to be done using typeahead phenomenon. Can anyone suggest me a solution to achieve this?

Below is the azure request:-

public async Task<List> ExecSuggest(string q)
{
try
{
// Execute /suggest API call to Azure Search and parse results
//string url = _serviceUri + AzureSuggestUrl + q;
string url = "https://meelosearchbasic.search.windows.net/indexes/indworkspacesearch/docs/suggest?api-version=2016-09- > >01&suggesterName=sgworkspacesearch&$top=5&$filter=TenantId eq '" + App.userTenantId + "'&search=" + q;
_httpClient = new HttpClient();
Uri uri = new Uri(url);
List Suggestions = new List();

           HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);
           AzureSearchHelper.EnsureSuccessfulSearchResponse(response);

           var obj = JsonConvert.DeserializeObject<SearchResult>(response.Content.ReadAsStringAsync().Result);
           Suggestions = obj.value;

           return Suggestions.Distinct().OrderBy(x => x.SearchText).ToList();
       }
       catch(Exception e)
       {
           return null;
       }
   }
Viewing all 204402 articles
Browse latest View live


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