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

EBADF (Bad file descriptor) with Andoid 10 target with PackageInstaller API

$
0
0

Before I updated to visual studio 19 and Android 10 (Q), I successfully installed third party apps with my app with the following code.

PackageInstaller installer = activity.PackageManager.PackageInstaller;
PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstallMode.FullInstall);
int sessionId = installer.CreateSession(sessionParams);
PackageInstaller.Session session = installer.OpenSession(sessionId);

var input = new FileStream(pfad, FileMode.Open, FileAccess.Read);
var packageInSession = session.OpenWrite("package", 0, -1);
input.CopyTo(packageInSession);
packageInSession.Close();
input.Close();
packageInSession.Dispose();
input.Dispose();

//That this is necessary could be a Xamarin bug.
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

Intent intent = new Intent(activity, activity.Class);
intent.SetAction("com.example.android.apis.content.SESSION_API_PACKAGE_INSTALLED");
PendingIntent pendingIntent = PendingIntent.GetActivity(activity, 0, intent, 0);
IntentSender statusReceiver = pendingIntent.IntentSender;

// Commit the session (this will start the installation workflow).
session.Commit(statusReceiver);

When i Dispose() the streams, i get an IOException: write failed (EBADF) bad file descriptor which would indicate a bad APK.

But this is unlikely because the code in visual studio 2017 works with the Android 9 target.

Hope somebody can help me and thank you in advance!


How to add dot indicators with ViewPager

$
0
0

I'm very new to development in general but am having a hard time finding tutorials/resources detailing how to add dot indicators to a view pager. these dots "show" which view page element you're on. If anyone has some tutorials/guides/code examples that i can take a look at it would be greatly appreciated

VirtualBox conflict issue with Hyper-V when trying to use macOS in virtual operating system

$
0
0

I'm a developer working with Xamarin on cross-platform technologies. My operating system is Win10 Pro. In my applications, I used my local machine as a running environment of UWP; and this works perfectly. I can use Visual Studio Emulator as a running environment of Android; samely this works perfectly. However, I cannot use iOS remote simulators in my virtual operating system. Until now, I have been connecting to remote iOS simulators, but in terms of cost and time, I decided to install virtual macOS on my computer.
According to my research, it can not be used macOS loaded on my virtual machine due to conflicting Hyper-V and VirtualBox. If I turned off Hyper-V, my all settings be removed and I cannot run an Android simulator in Visual Studio. If I turned on Hyper-V I cannot install macOS on my virtual machine despite of running Android. How can I solve this conflicting?
Here is my virtual machine installing macOS error in VirtualBox:

PopUpMenu disables other control when is open

$
0
0

I'm facing an issue, when NSMenu.PopUpMenu is called then it disables my NSTextField even if I don't select any item from NSMenu.
My NSMenu belongs to another custom control to show items as PopUpButton(ComoboBox).

Here is part of my code:
CGPoint loc = new CGPoint(0f, 0f);
var result = PopUpMenu.PopUpMenu(PopUpMenu.Items[0], loc, this); //From here my NSTextField changes to disabled and I cannot be edited

Here is my NSTextField before open NSMenu:

After NSMenu is open:

THESE CONTROLS ARE SHOWN IN A DIALOG WINDOW. I have the same controls in other window(no dialog) and they work correctly.
Dialog uses storyboard and viewcontroller to be loaded in the window.

App runs in debug mode, crashes in release mode

$
0
0

Hi!

When running my xamarin forms app on android in debug mode, all works fine.
But when running it in release mode the app crashes after showing the splash screen. (I have deleted the debug version from phone before installing the release version).
Below you can see the application output.
If i delete "Mono Android-23 Support" and "Mono shared Runtime" and reinstall the release version my app does NOT crash in release mode.
So far okay - but will it work later when somebody installs my app from Play store?

What are your experiences with debug and release mode?

Thanks a lot and have a nice day!
Andreas

Application Output: [AndroidRuntime] Shutting down VM [AndroidRuntime] FATAL EXCEPTION: main [AndroidRuntime] Process: Alarm.Droid, PID: 8858 [AndroidRuntime] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811) [AndroidRuntime] Caused by: java.lang.reflect.InvocationTargetException [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method) [AndroidRuntime] at java.lang.reflect.Method.invoke(Method.java:372) [AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016) [AndroidRuntime] ... 1 more [AndroidRuntime] Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.IO.FileNotFoundException: Could not load file or assembly 'alarm' or one of its dependencies. The system cannot find the file specified. [AndroidRuntime] File name: 'alarm' [AndroidRuntime] at System.AppDomain.Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence) <0x003d4> [AndroidRuntime] at System.AppDomain.Load (System.Reflection.AssemblyName) <0x0001f> [AndroidRuntime] at (wrapper remoting-invoke-with-check) System.AppDomain.Load (System.Reflection.AssemblyName) <0x0007b> [AndroidRuntime] at System.Reflection.Assembly.Load (System.Reflection.AssemblyName) <0x0001f> .....

Push Notification

$
0
0

Hi
If you can help in the implementation of this
Introduce a service that is free and not part of Iran's sanctions

How to disable a listview resetting scroll to the top after reassigning the bound list

$
0
0

I am working in Xamarin.Forms on a UWP project, and I have a Listview that has an ItemsSource bound to an ObservableCollection on my view model. When I reassign the Property that is bound to that list to a new ObservableCollection, I have noticed that it sets the scroll to the top of the list. I assume that that is intended behavior, but I was wondering if anyone knows of way to preserve the ScrollY position of the Listview after reassigning the bound property to a new ObservableCollection? I was thinking I could just grab the y position of the list before reassigning the property and then scroll to that position after the deed is done, but it seems the Listview has no ScrollTo method for y position, only specific objects in the list.

If you're unsure what I mean when I talk about reassigning the Property:
my Listview is bound like this:

<Listview ItemsSource="{Binding MyCollection}"
...
...
>
    ...
</ListView>

My VM has a Command in it--bound to another control on my view--that does something like this:

MyCollection = new ObservableCollection(MyCollection +/- SomeNewItems);

I should mention, that I am aware you can Add and Remove from the ObservableCollection directly on the main thread instead of just replacing it, but I would prefer to do it this way if at all possible.

Nagging problem with DownloadManager

$
0
0

I've implemented a file download function in our Android App using DownloadManager.

In a "old" API 23 Android real phone, I can use it without any problems. The same on en emulator using API 23 also.

But if I use API level 27 or above in a emulator, I can download a small file without any problems, but if the file is larger, it stops giving a reason or 1008 meaning "Canno't resume".

I ordre to troubleshoot, I built an app that has a simple UI consisting of 2 button. One downloads a zip file of 217kb and the other one a zip file of 34 461 kb.

On a API 23 level app... Everything works fine, in API 27 or above, the big file fails the lighter one is fine!

Both phones have plenty of free space!

Also, on the API 23 app, I can see the file being downloaded in the top bar, but on API 27 or above I can't see it.

Any clues ?


Binding listview anomaly

$
0
0

Hi,
I have a view model that takes data from openweathermap. The data are stored in a list (40 lines in forecast). There are also 5 other lists that filter the data by day1, day2..day5. My xaml binds the data in different listview. Listviw1 for day1 etc. On xamarin.forms 3.6 it works well. On version 4.4 the bind is confusing and shows all the data (40 data) on each listview (1,2..5).
If I bind after processing all the filters on day1, day2 etc. it works correctly.
What could be the problem?
Thanks.

<ListView ItemsSource="{Binding Day0.Items}"
              HasUnevenRows="True"
              CachingStrategy="RecycleElement"
              IsPullToRefreshEnabled="True"
              RefreshCommand="{Binding GetWeatherCommand}"
              IsRefreshing="{Binding IsBusy, Mode=OneWay}"
              RowHeight="45"
              x:Name="ListViewWeather0">

Macbook Pro and Energy Saver settings

$
0
0

I have my windows machine paired with my Macbook Pro and can't figure out what the best setup to keep the Macbook 'alive' while im working on my Windows machine.

Ideally, I just want to keep my macbook on the side (either plugged into AC or battery). I am finding that when my macbook screen shuts off, the pairing dies. So I have to constantly move my mouse on the macbook.

Is the macbook going to sleep when the screen shuts off? What should I set it to if I just want to keep it awake while its paired to windows?

Azure AD Without Browser

$
0
0

I'm looking to make use of Azure AD from a Xamarin.Forms app for account creation and authentication. All of the sample code that I see uses Azure AD B2C, which uses some form of Web browser with a re-direct back to the app. I need full control of my signup and login flow so the browser method is not ideal for my use.

Is there a way to use Azure AD without using a browser at all? Like, just make the calls from a forms app to Azure AD?

Urhosharp Status/ Support

$
0
0

What is the status of Urhosharp as a component maintained by Microsoft? I'm aware that this is simply a Binding of the original c++ Urho3d engine, but the last urhosharp nuget update seems to have been more than a year ago.

Im at the beginning of a new project which requires a 3D visualization, and id love to use urhosharp for this, but am uncertain as to it's future. What are the current plans for supporting urhosharp? If and when Urho3d 1.8 is released will urhosharp follow?

Spin wheel UI in Xamarin forms

$
0
0

Hi,

There is this new client for us, who wants a spin wheel contest in the app, the spin wheel would have coupon codes and offers.
Similar to a Roulette spinner as shown below. Do we have any plugins or implementation already similar to this.
Or should i start working on this spinner using animations and custom renderers to achieve this.

Thanks,
Shri Guru

message: Couldn't connect to logcat, GetProcessId returned: 0

$
0
0

Hello... When executing some examples, it shows me the following message:
Couldn't connect to logcat, GetProcessId returned: 0
As it is solved?

Assembly GetManifestResourceNames and GetManifestResourceStream not working on Android

$
0
0

Hi.

I have some code in a previous version of Xamarin.Forms which loads an embedded ressource.
After upgrading (actually making a totally new Xamarin.Forms project) it does not work as expected on Android (No resources found).
On iOS it works as expected, and 1 resource is found.
The "EmbeddedContent.txt" is compiled as "Embedded Resource", and the dll is a .net Standard 2.0

The code is as follows:

Assembly assembly = typeof(EmbeddedResourceProject.Class1).GetTypeInfo().Assembly;
string[] resources = assembly.GetManifestResourceNames();
Stream stream = assembly.GetManifestResourceStream("EmbeddedResourceProject.EmbeddedContent.txt");

I have tried using Xamarin.Forms V4.4.0.991265 and V4.5.0.530.
I am targeting Android 9.0.
I have added a full example (Please look in file: App.xaml.cs)

I hope someone can help me.


How to select multiply items inside collection view

$
0
0

Hi there, I'm trying to select multiply items inside collection view but I'm getting the first selected item only

<CollectionView ItemsSource="{Binding themeByCategory, Mode=TwoWay}" 
                                SelectionMode="Multiple"
                                SelectionChanged="CollectionView_SelectionChanged_2">

                    <CollectionView.ItemsLayout>
                        <GridItemsLayout Orientation="Horizontal" Span="4"></GridItemsLayout>
                    </CollectionView.ItemsLayout>

                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Grid Padding="10">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <Image Source="{Binding mainImage}">
                                </Image>
                            </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

 private void CollectionView_SelectionChanged_2(object sender, SelectionChangedEventArgs e)
        {
            string item = (e.CurrentSelection.FirstOrDefault() as GalleryImageListReturnDto).mainImage;
            if (item != null)
            {
                selected.Add(item);
            }
        }

stop back ground task at Xamarin Form

$
0
0

hey, my friends, I have some issues to stop the video that works in the background!
this is my code:

public HomeTabPage()
{
InitializeComponent();
CrossMediaManager.Current.PlayFromResource("MY VIDEO LINK");
}

what the function that will stop all the task on the background in the Android and iOS

Toggling visibility of a label in a listview

$
0
0

I am new to Xamarin. I have a listview which is bound to an ObservableCollection with data coming from sqlite.

List view has two labels. I want to hide one of the labels (lblGroup) when someone clicks on the toolbar menu button. This code is not working.

Here's the code



<ListView.ItemTemplate>








</ListView.ItemTemplate>

public ObservableCollection itemsObs;
public ItemDetails()
{
InitializeComponent();
LoadItems();
}

private async LoadItems()
{
List items = _con.QueryAsync(Queries.ItemsById(ItemsId));
itemsObs = new ObservableCollection(items);
lstItems.ItemsSource = itemsObs ;
}

private void menu_Clicked(object sender, EventArgs e)
{
versesObs.ToList().ForEach(a => a.IsGroupVisible = false);
}

How to revert back to AndroidX migration?

$
0
0

I know that there is warning that this is not revertible but I would like to know if that is really the case? is there no way to revert back to AndroidX migration. I did that on a different branch to test it and i saw that some syncfusion libraries are depends on older support libraries. I have reported it to syncfusion and they said that they will make it ready to next release. Now i cant even debug on my original master branch which has no migration? Is that something to do with AndroidSDK or NDK? should i just delete the instance and redownload a fresh AndroidSDK. what is this about? There must be a way certainly.

Only the original thread that created a view hierarchy can touch its views exception Xamarin.Android

$
0
0

I have the following screen:

When I click on Ponentes ImageButton , after few seconds SpeakersActivity opens. After clicking on Ponentes ImageButton I don't want to stay on its screen for several seconds, but I want SpeakersActivity to open immediately with loadingSpinner ProgressBar while the data in SpeakersActivity is loading. I put the code which causes the delay in a thread in the OnCreate method of SpeakersActiviy:

protected override async void OnCreate(Bundle savedInstanceState)
{
    .....
    .....

    loadingSpinner.Visibility = ViewStates.Visible;
    await Task.Run(() =>
    {
        //get all the speakers from the db
        allSpeakers = DatabaseHelper.GetAllFromTable<Speaker>("speakers.db");

        //get only the international spakers
        internationalSpeakers = allSpeakers.Where(x => x.Nationality.Equals("international")).ToList();

        //get only the national speakers
        nationalSpeakers = allSpeakers.Where(x => x.Nationality.Equals("national")).ToList();

        //fill in the RecyclerView with data
        speakersRecyclerView = FindViewById<RecyclerView>(Resource.Id.speakersRecyclerView);
        speakersLayoutManager = new LinearLayoutManager(this);
        speakersRecyclerView.SetLayoutManager(speakersLayoutManager);
        speakersAdapter = new SpeakersAdapter(speakers);
        speakersAdapter.ItemClick += OnItemClick;
        speakersRecyclerView.SetAdapter(speakersAdapter);

        loadingSpinner.Visibility = ViewStates.Gone;
    });
    .....
    .....
}

I get Only the original thread that created a view hierarchy can touch its views exception. What is the cause of that exception and how can I achieve what I want? If there is a single command solution as mine:

await Task.Run(() => {.....}); 

it would be better, so if another person reads my code in the future, he doesn't wonder too much what's going on.

Here is the SpeakersActivity.axml :

<LinearLayout>
    <Toolbar>
        <TextView/>
    </Toolbar>
    <LinearLayout>
        <TextView/>
        <TextView/>
    </LinearLayout>
    <android.support.v7.widget.RecyclerView
        android:id = "@+id/speakersRecyclerView"/>
    <ProgressBar
        android:id = "@+id/loadingSpinner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:indeterminateDrawable="@drawable/animdraw"
        android:visibility="gone"
        android:layout_gravity="center"/>
</LinearLayout>

I skipped View's attributes because they are irrelevant.

Viewing all 204402 articles
Browse latest View live


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