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

Linker throws error if solution has .net standard library with system.drawing.image output parameter

$
0
0

Hi

My solution has a .net standard library project.

This project has a class which returns System.Drawing.Image in a public static method.

Android project builds fine in debug mode and in release mode when linker is turned off.

However, when linker is set to "Sdk Assemblies", it throws error: "Cannot resolve System.Drawing.Image"

Pl advise

Thanks


Enable NFC hardware from within application

$
0
0

Hi, I'm making a XF App that uses NFC functionality to allow a user to transmit data from there phone to an NFC terminal (Currently only android but IOS in the future). The app uses Card Emulation Mode (not reader/writer mode) to achieve this and works fairly well.

The part i am having a problem with is providing a convienient way for the user to turn on the NFC functionality of the device. The way i would like this to work is as the page loads check if NFC is on, if not provide a button that will then turn on the NFC chip without having to leave the App and go into settings.

I am new to xamarin and can't find a good example of how to do this. Some examples i found mentioned using intents but that was purely android development and not sure if there is an equivalent in xamarin. Below is some working code in one of my XF forms page. Any help would be great, cheers

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

        if (!viewModel.UserItems.Any())
            viewModel.LoadItemsCommand.Execute(null);

        NfcAdapter adapter = NfcAdapter.GetDefaultAdapter(Android.App.Application.Context);

        if (adapter == null)
        {
            DisplayAlert("NFC State", "No nfc adapter available", "ok");
        }
        else
        {
            if (adapter.IsEnabled)
            {
                DisplayAlert("NFC State", "the nfc is ENABLED", "ok");

            }
            else
            {
                DisplayAlert("NFC State", "the nfc is DISABLED", "ok");
            }
        }
    }`

is there a Tabbed view in Xamarin.forms?

$
0
0

Hello,
any idea how to make a Tabbed view in xamarin.forms,
i only found Tabbed page which is not possible to put it inside a content page!

choosing Xamarin.forms is bad choice? should i've used each platforme beside with xamarin.android and xamarin.ios!

Thanks in advance

After upgrading Xamarin.Forms from version 3.0.0.561731 to 3.1.0.583944, I get a compile error.

$
0
0

After upgrading Xamarin.Forms from version 3.0.0.561731 to 3.1.0.583944, I get the following error for two of my XAML pages. However, I do not have a member with the same name (except for a constructor). Does anyone know why this build error may be occurring. I posted the code behind for one of the classes below.

Build error:
1>obj\Debug\netstandard2.0\Views\Manifest\ManifestListPage.xaml.g.cs(20,51,20,67): error CS0542: 'ManifestListPage': member names cannot be the same as their enclosing type
1>obj\Debug\netstandard2.0\Views\Manifest\ManifestPage.xaml.g.cs(20,51,20,63): error CS0542: 'ManifestPage': member names cannot be the same as their enclosing type
1> 0 Warning(s)
1> 2 Error(s)
1>
1>Time Elapsed 00:00:00.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If I downgrade Xamarin.Forms back to the previous version, the error disappears.

**Here is the complete code for the first error for the ManifestListPage.xaml.cs file (class):
**
using TPS_Mobile_NS.Models.Database.Tables.Definition;
using TPS_Mobile_NS.Services;
using TPS_Mobile_NS.ViewModels.Manifest;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace TPS_Mobile_NS.Views.Manifest
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ManifestListPage : ContentPage
{
public ManifestListPage()
{
ViewModel = new ManifestListViewModel(new PageService());
InitializeComponent();
}

    public ManifestListViewModel ViewModel
    {
        get { return BindingContext as ManifestListViewModel; }
        set { BindingContext = value; }
    }

    protected override void OnAppearing()
    {
        ViewModel.Commands["LoadDataCommand"].Execute(null);
        base.OnAppearing();
    }

    private void ManifestSelected(object sender, SelectedItemChangedEventArgs e)
    {
        if (manifestList.SelectedItem != null)
        { 
            ViewModel.Commands["NavigateCommand"].Execute(new ManifestDetailListPage(e.SelectedItem as Manifest_T));
        }

    }
}

}

Java.Lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid Error

$
0
0

Hi Xamarin Forum

I got this when I try to use OneSignal for making some notification

here is what happened

  1. I sent the message through OneSignal Dashboard
  2. Upon sending the debugger stopped and display this error

Java.Lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver

How to hide keyboard when focus Entry

$
0
0

I have a Xamarin.forms project, I have a page with an Entry control, I want to hide the keyboard when the Entry gets the focus ,because it is for scanning barcode labels, how can I achieve that?
The following code can implement hidden keyboard, but the keyboard occasionally shows,especially when the entry is empty.
How can I avoid it?thanks
here is my caode :
Control.InputType = 0;
Control.ShowSoftInputOnFocus = false;
InputMethodManager inputMethodManager = Control.Context.GetSystemService(Context.InputMethodService) as InputMethodManager;
inputMethodManager?.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None);

Xamarin.Forms bug? System.ObjectDisposedException: Cannot access a disposed object

$
0
0

Hi,

My Android Xamarin.Forms application uses a Navigation stack to display various views, I often have a list on a screen (A) that once a cell is clicked I push onto the stack a new screen (B), the user completes some form fields and then clicks a button to save. Once they click the 'save' button a task is created on the thread pool to asynchronously perform some work (no async/await and no dependency on any UI) and the view is popped back to screen (A).

Once the task is completed, it fires a simple event using the PubSub library, on the UI thread, so screen (A) has the opportunity to refresh from the local database and it does.

The problem is that when I go to drag the updated list on screen (A), the app crashes with an ObjectDisposedException intermittently (like 1 in 50 times)...

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Views.GestureDetector'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:57
  at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x0002c] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.GestureDetector.cs:1546
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0003f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:101
  at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:3558
  at at (wrapper dynamic-method) System.Object:4eaabbb9-8c1c-4ea1-b505-44c325bbb1ab (intptr,intptr,intptr,intptr)

I'm not sure why it says that I cannot access a disposed object, I'm interacting with a list with a gesture detector, it's on-screen, so it's not disposed.

Is this a bug in Xamarin.Forms?

On a similar note, if I modify an MVVP property that notifies listeners that a property has changed (I always check it's on the UI thread first), then if that's bound to a Xamarin.Forms list but it's not currently on-screen, presumably Xamarin.Forms will not barf ? After-All it's just off-screen and should still bind okay?

Calendar plugin

$
0
0

Hi Xamarin forum

is there any calendar plugin for xamarin forms aside syncfusion that can plot events on the calendar

Thanks


Problem with touch gesture recognizer in IOS

$
0
0

Hello,
I've a complex layout that is making me crazy because I'm trying to make working a tap gesture recognizer in my ios project that works fine in Android project but not in Apple one.

My layout is composed of different levels of grids, nested one inside others.

I tried with a lot of temptatives discovering that until the second level of grid I can use a tapgesture and my application receive a notification, while if I try to get a user input inside the second grid it doesn't work.

I tried with a tapgesture recognizer and with a simple button, but all the elements I have inside the second grid are not fired.
I also tried to use the InputTransparent property without success.
I also tried to create a custom rendered for the Grid where to set UserInteractionEnabled or to prevent to capture the input like explained in this thread:
https://forums.xamarin.com/discussion/55376/pass-click-tap-event-through-levels-of-relativelayout
but I wasn't able to find the right way to do it.

Can somebody point me in the right direction to have my tapgestures recognizers working in ios like they already do in Android?

Thank you

Android.OS.FileUriExposedException since updating android to API 28

$
0
0

Our app offers the users to 'Download Latest Version' whenever we roll out an updated version of the app on our own servers. We've recently updated the Target to 28 (Android 9.0) and the following code now causes the Android.OS.FileUriExposedException as follows:

            Intent promptInstall = new Intent(Intent.ActionView).SetDataAndType(Android.Net.Uri.FromFile(new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/download/" + filename)), "application/vnd.android.package-archive");
            promptInstall.AddFlags(ActivityFlags.NewTask);
            Android.App.Application.Context.StartActivity(promptInstall);

The result:

[0:] Android.OS.FileUriExposedException: file:///storage/emulated/0/download/app.apk exposed beyond app through Intent.getData()
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <034d4a9852dd45bea9353cc7776c99f0>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <034d4a9852dd45bea9353cc7776c99f0>:0 
  at Android.Content.ContextWrapper.StartActivity (Android.Content.Intent intent) [0x00031] in <a10f61e70eeb434e952fef884856c199>:0 
  at App.Droid.FileInteractions.SaveBinary (System.String filename, System.Byte[] bytes) [0x0004a] in C:\tr\App\App\App.Droid\FileInteractions.cs:20 
  at App.ViewModels.SettingsViewModel.client_DownloadUpdateCompleted (System.Object sender, App.TmService.DownloadUpdateCompletedEventArgs e) [0x000b6] in C:\tr\App\App\App\ViewModels\SettingsViewModel.cs:475 
  --- End of managed Android.OS.FileUriExposedException stack trace ---
android.os.FileUriExposedException: file:///storage/emulated/0/download/app.apk exposed beyond app through Intent.getData()
    at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
    at android.net.Uri.checkFileUriExposed(Uri.java:2351)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:9043)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:9004)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1519)
    at android.app.ContextImpl.startActivity(ContextImpl.java:791)
    at android.app.ContextImpl.startActivity(ContextImpl.java:768)
    at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)

Could some one help me with this please? My android knowledge is limited and I can't seem to find a 'workable' solution to this problem that doesn't involve half a day to implement...

IntentService help to run background even the app is closed

$
0
0

Hi guys I need some help on my app when the user close the app my sync process is still running. Right now, my achievement is just when the user minimize the app is still running.

In my MainActivity
var alarmIntent = new Intent(this, typeof(MyBroadcastReceiver)); var pending = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); var alarmManager = GetSystemService(AlarmService).JavaCast<AlarmManager>(); alarmManager.SetInexactRepeating(AlarmType.RtcWakeup, SystemClock.ElapsedRealtime(), 120000, pending);

In my Receiver

    [BroadcastReceiver]
    public class MyBroadcastReceiver: BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            var serviceIntent = new Intent(context, typeof(ReverseGeoCodeLocationService));
            serviceIntent.PutExtras(intent);
            context.StartService(serviceIntent);

        }
    }

In my Service

   [Service]
    class ReverseGeoCodeLocationService : IntentService
    {   
        protected override void OnHandleIntent(Intent intent)
        {
            // Code to reverse GeoCode is omitted for clarity.
            MyCurrentLocationService obj = new MyCurrentLocationService(new MyLocalStorageService(), this.ApplicationContext);
            obj.OnTimedEvent();
        }
    }

Chat Application based on Xamarin forms Source code

$
0
0

Hi All

I notice many questions about developing a chat application in Xamarin forms .

So i decide to release a source code for you guys and for all beginners to develop there self more and to use some ready code if they like

WoWonder Messenger v1.3

Source code >> https://github.com/Doughouzlight/Xamarin_Forms_Wowonder-Messenger-v1.3

The application is based on Xamarin forms which is related to the Wowonder Social script

The solution includes more than 20+ features, The new versions after this version has been switched and developed on Xamarin android

Reading Logo in Qrcode

$
0
0

Hi Guys,

I am currently using Zxing.Net.Mobile to read a barcode scanning. How can I get a logo from barcode.

Please help on this.

Why is delegate.BeginInvoke erring on the UWP Platform?

$
0
0

This is my first attempt at implementing an asynchronous delegate. So, maybe I'm doing something incorrectly. However, this works just fine for my Android project. But, when I run this on my UWP project, I get a PlatformNotSupportedException. Does the UWP platform not support this .Net C# library method? If I change this delegate back to synchronous and call the Invoke method, I have no problems. But, the underlying method that the delegate calls is an asynchronous method, so I think I need to make the delegate asynchronous to make it thread safe. At least, that is my understanding.

    private void ChangeCompletedManifest(TPSArgs tpsArgs)
    {
               _changeManifestRecord.BeginInvoke(tpsArgs, new AsyncCallback(CallbackMethod), _changeManifestRecord);
     }

    private void CallbackMethod(IAsyncResult result)
    {
        ManifestPage.ChangeManifestRecord changeManifest = (ManifestPage.ChangeManifestRecord)result.AsyncState;
        changeManifest.EndInvoke(result);
    }

Xamarin.iOS Custom url schemes

$
0
0

I am doing Xamarin.Forms app with deep linking but when I click on certain url link
method in PCL project in App.xaml.cs named: protected override void OnAppLinkRequestReceived(Uri uri) is never called.
So the link is opening with a browser.

So I started to make a workaround with custom implementation on Android and iOS project, and everything works fine on Android but on iOS it does not work.
Can someone see did I miss something?

Link is always opened with a browser.
On Android it is working fine but on iOS it does not.
Here are two pictures from AppDelegate.cs and Info.plist, did I miss something?
Breakpoint is also never hit.
When I click on url https://strukturnifondovi.hr in contacts app in iPhone simulator it always open a browser.


How to use binding with condition ?

$
0
0

I want to show Activity Name from Sqlite database ,but I dont to show them all , I want to show only them who have the IDUser=null .
How can I do that , this is my code but its showing all !


TabbrdPage tab Ttitles are wrapping as the tabs are no more scrollable

$
0
0

I have modified the TabbedPage app created by the Tabbed Page Template to contain 6 tabs. I find all 6 tabs are accommodated within the width of the display and the Tab's Titles are now wrapping, that too awkwardly. See the screenshot attached.

Previously we used to get a scrollable tab Titles. How can I get back to it?

Open PDF in Android default PDF reader

$
0
0

Hi,

I'm searching a way to open a PDF (stored in local) in the Android default PDF reader in Xamarin.Forms.
I'm using a webview for iOS but WebViews on Android cannot open a local PDF.

var browser = new WebView ();

if (Device.OS == TargetPlatform.iOS) {
    browser.Source = @App.DocumentUrl;
} else if (Device.OS == TargetPlatform.Android) {
    Device.OpenUri (new Uri (@App.DocumentUrl)); // Don't work
}

Content = browser;

Did someone have a solution ?

Thanks.

How to navigate page detail of detail page in master detail page

$
0
0

Hello i am using master detail page in my application now i have following hierarchy

Master Detail Page
-User Registration Step1
-- User Registration Step2
---User Registration Step3

So now i am at User Registration Step1 now i want to navigate to next step (User Registration Step2).how can i navigate in step2 ??
also i want to display back arrow in navigation bar in step2

Chat Application based on Xamarin forms Source code

$
0
0

Hi All

I notice many questions about developing a chat application in Xamarin forms .

So i decide to release a source code for you guys and for all beginners to develop there self more and to use some ready code if they like

WoWonder Messenger v1.3

Source code >> https://github.com/Doughouzlight/Xamarin_Forms_Wowonder-Messenger-v1.3

The application is based on Xamarin forms which is related to the Wowonder Social script

The solution includes more than 20+ features, The new versions after this version has been switched and developed on Xamarin android

Viewing all 77050 articles
Browse latest View live


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