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

How to Detect disconnected device from the WIFI network

$
0
0

Hi All,

I am creating the offline data transfer application.Now i need to detect the disconnected device.

For example device A,B,C were connected in the WIFI(no internet).We are transfering the data to A and B and C. A and B received successfully,C device did not received because C is disconnected from the WIFI network(due to distance between device and WIFI exceeds).

Please suggest me if anybody have an idea to overcome this issue.

Thanks in advance


Generated Bindings Remove Generics

$
0
0

I am trying to bind an abstract class that uses generics:

public abstract class ResponseCallback<T>
{
  public ResponseCallback() {}

  public abstract void onResponse(Response<T> paramResponse);

  public abstract void onError(int paramInt, String paramString);
}

However, the generated C# file does not have this

 // Metadata.xml XPath class reference: path="/api/package[@name='com.test.test.module.api']/class[@name='ResponseCallback']"
[global::Android.Runtime.Register ("com/test/test/module/api/ResponseCallback", DoNotGenerateAcw=true)]
[global::Java.Interop.JavaTypeParameters (new string [] {"T"})]
public abstract partial class ResponseCallback : global::Java.Lang.Object {

    internal    new     static  readonly    JniPeerMembers  _members    = new XAPeerMembers ("com/test/test/module/api/ResponseCallback", typeof (ResponseCallback));
    internal static new IntPtr class_ref {
        get {
            return _members.JniPeerType.PeerReference.Handle;
        }
    }

    public override global::Java.Interop.JniPeerMembers JniPeerMembers {
        get { return _members; }
    }

    protected override IntPtr ThresholdClass {
        get { return _members.JniPeerType.PeerReference.Handle; }
    }

    protected override global::System.Type ThresholdType {
        get { return _members.ManagedPeerType; }
    }

    protected ResponseCallback (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) {}

    // Metadata.xml XPath constructor reference: path="/api/package[@name='com.test.test.module.api']/class[@name='ResponseCallback']/constructor[@name='ResponseCallback' and count(parameter)=0]"
    [Register (".ctor", "()V", "")]
    public unsafe ResponseCallback ()
        : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
    {
        const string __id = "()V";

        if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
            return;

        try {
            var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null);
            SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
            _members.InstanceMethods.FinishCreateInstance (__id, this, null);
        } finally {
        }
    }

    static Delegate cb_onError_ILjava_lang_String_;

    static Delegate GetOnError_ILjava_lang_String_Handler ()
    {
        if (cb_onError_ILjava_lang_String_ == null)
            cb_onError_ILjava_lang_String_ = JNINativeWrapper.CreateDelegate ((Action<IntPtr, IntPtr, int, IntPtr>) n_OnError_ILjava_lang_String_);
        return cb_onError_ILjava_lang_String_;
    }

    static void n_OnError_ILjava_lang_String_ (IntPtr jnienv, IntPtr native__this, int p0, IntPtr native_p1)
    {
        global::Com.Test.Test.Module.Api.ResponseCallback __this = global::Java.Lang.Object.GetObject<global::Com.Test.Test.Module.Api.ResponseCallback> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
        string p1 = JNIEnv.GetString (native_p1, JniHandleOwnership.DoNotTransfer);
        __this.OnError (p0, p1);
    }


    // Metadata.xml XPath method reference: path="/api/package[@name='com.test.test.module.api']/class[@name='ResponseCallback']/method[@name='onError' and count(parameter)=2 and parameter[1][@type='int'] and parameter[2][@type='java.lang.String']]"
    [Register ("onError", "(ILjava/lang/String;)V", "GetOnError_ILjava_lang_String_Handler")]
    public abstract void OnError (int p0, string p1);

}

[global::Android.Runtime.Register ("com/test/test/module/api/ResponseCallback", DoNotGenerateAcw=true)]
internal partial class ResponseCallbackInvoker : ResponseCallback {

    public ResponseCallbackInvoker (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) {}

    internal    new     static  readonly    JniPeerMembers  _members    = new JniPeerMembers ("com/test/test/module/api/ResponseCallback", typeof (ResponseCallbackInvoker));

    public override global::Java.Interop.JniPeerMembers JniPeerMembers {
        get { return _members; }
    }

    protected override global::System.Type ThresholdType {
        get { return _members.ManagedPeerType; }
    }

    // Metadata.xml XPath method reference: path="/api/package[@name='com.test.test.module.api']/class[@name='ResponseCallback']/method[@name='onError' and count(parameter)=2 and parameter[1][@type='int'] and parameter[2][@type='java.lang.String']]"
    [Register ("onError", "(ILjava/lang/String;)V", "GetOnError_ILjava_lang_String_Handler")]
    public override unsafe void OnError (int p0, string p1)
    {
        const string __id = "onError.(ILjava/lang/String;)V";
        IntPtr native_p1 = JNIEnv.NewString (p1);
        try {
            JniArgumentValue* __args = stackalloc JniArgumentValue [2];
            __args [0] = new JniArgumentValue (p0);
            __args [1] = new JniArgumentValue (native_p1);
            _members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
        } finally {
            JNIEnv.DeleteLocalRef (native_p1);
        }
    }

}

As you can see, I am missing the public abstract void onResponse(Response<T> paramResponse); node in my generated code. What can I do to get this and the generics included in the C# code? I have been googling all night and cant find anything.

Some articles suggest adding to the Additions file in the binding project, but I can't figure out how to get it to work and there is no documentation on the Addtions section of the binding process.

NOTE: I changed the paths in the Metadata comments as it is proprietary.

How can I change the hamburger icon for another one in Xamarin.Forms for Android?

$
0
0

How can I change the hamburger icon for another one in Xamarin.Forms for Android?

I tried a lot of methods to change the three bars (hamburger icon) for another icon with Xamarin.Forms, but it seems to always use the burger.

For iOS I already checked, and it works really great, but for some reason I can't show the same picture in Android.

For Android I'm using a default project created with the latest Xamarin Studio 6. It generates a MainActivity of type FormsAppCompatActivity.

Is there any way to change the picture consistently?

How to suppress "warning: linking against dylib not safe for use in application extensions"?

$
0
0
Hello,

I'm trying to add the WebRTC framework to my iOS app's broadcast extension through a binding library, but I get the error above. In Xcode you can suppress it in the build settings, but I have no idea where a similar option can be found in Visual Studio. Is it possible to suppress this error in Xamarin?

Reproduce carousel view behaviour/animation/transition to a horizontal scroll view.

$
0
0

Hey developers,
I have so far tried to use a carousel view due to its ease of use and of course its performance. But I tried to show the tail of each UI elements (let's say we've a bunch of cards) whatever the position is as shown in the picture. I've googled a lot and posted another question in this forum but since then I changed the project UI a little bit so I ignored the given solution and now I am on my own again, I resolved it (show the next card's tail or/and the previous), I'll write down the structure I used in XAML but first let me highlight my requirements.
I want to reproduce the behaviour, animation/transition on swiping of the carousel view to my view, because I am actually using a horizontal scroll view with a Flex layout inside.
Here is the structure :

Now I've tried two options :
1- Use of Scrolled event in the scroll view but that hasn't been a great option because it fire the events (animation or transition) after the scroll is done, in my case it should fire the event since scrolling started.
2- Use of SwipeGestureRecognizer on Scrollview, FlexLayout and BoxView : couldn't get a stable behaviour on the 2 first attempts but when I used a BoxView I couldn't get each StackLayout (the StackLayout is my card) inside the BoxView (It wasn't built for that).

Here is my UI after I used a horizontal scroll view :

here is the behaviour I wanted to reproduce to my view :
https://media.giphy.com/media/l0NwH3XDSYhQ6l4TC/giphy.gif

How to Enlarge the image when we tap on it?

$
0
0

My requirement is when i clicked on the image i need to show image as zoom out

FreshMVVM Master detail with custom MasterPage

$
0
0

Hello
I use FRESHMVVM in my app.
I created a massterdetail page as well:

var masterPage = FreshPageModelResolver.ResolvePageModel();
var detailPage = FreshPageModelResolver.ResolvePageModel();
var masterDetailNav = new FreshMasterDetailNavigationContainer();
masterDetailNav.Init("Menu");
masterDetailNav.Master = masterPage;
masterDetailNav.Detail = detailPage;
MainPage = masterDetailNav;
}

I would like that when a MenuItem is pressed it is navigated to the new page keeping the menu present.

I am doing this way but the new page is opened without menu.

await CoreMethods.PushPageModel(item.ViewModelType);

Can you help me?
Thank you

Notification Icon not display properly Xamarin Android

$
0
0

I have problem setting up a notification image to display properly.

Below is the original image, with file path:

myApp\Resources\drawable\Icon.png

Dimensions: 72x72pixels, 32bit depths

enter image description here

The problem:

It displays like below.

enter image description here

Below is the code. The code seems working correctly for previous version which displays it properly.

 public class MyServiceConnection : Java.Lang.Object, IServiceConnection
    {
        private string _appName;

        public MyServiceConnection(string appName)
        {
            _appName = appName;
        }

        public void OnServiceConnected(ComponentName name, IBinder service)
        {
 var intent = new Intent(Application.Context, typeof(ManifestActivity));
            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(Application.Context, 0, intent, PendingIntentFlags.UpdateCurrent);

            var notificationBuilder = new NotificationCompat.Builder(Application.Context)

                .SetSmallIcon(Resource.Drawable.Icon)
                .SetContentTitle(_appName)
                .SetAutoCancel(true)
                .SetContentIntent(pendingIntent);

            var notificationManager = NotificationManager.FromContext(Application.Context);
            var notification = notificationBuilder.Build();
            notificationManager.Notify(1, notification);

            var serviceBinder = service as MyService.Binder;
            serviceBinder.StartForeground(1, notification);
    }

    public void OnServiceDisconnected(ComponentName name)
        {
        }
}

Envoironments:

 android:minSdkVersion="15" android:targetSdkVersion="27" 

FirebasePushNotificationPlugin

$
0
0

HI,
I am using Firebse Push notification plugin - https://github.com/CrossGeeks/FirebasePushNotificationPlugin
in Android , we can define the activity to be shown when the notification is clicked - FirebasePushNotificationManager.NotificationActivityType
Is there similar way to define for ios.
Currently when clicking on push notification the app crashes on ios.

Release vs. AppStore configuration

$
0
0

As can be seen here there are different configurations available:

-Debug
-AdHoc
-Release
-AppStore

Which bundle signing option do you use for each? These are the ones I currently use:

-Debug: Automatic
-AdHoc: Ad-Hoc (Automatic)
-Release: Automatic
-AppStore: my created distribution profile

Except for debug I always create an ipa file (iOS IPA Options). How do you do that?

What is the difference between Release and AppStore configuration? What is used for what?

Good morning, i can´t resolve Plugin.InputKit error after install it, it appears follow code error:

$
0
0

Can not resolve reference: Plugin.CurrentActivity, referenced by Plugin.InputKit. Please add a NuGet package or assembly reference for Plugin.CurrentActivity, or remove the reference to Plugin.InputKit. SoftcomunaApp.Android

Xamarin Forms Android blank screen in Release but works fine in Debug

$
0
0

Hi, I have literally spend the last three days stripping down my code to a blank Xamarin application that comes installed with visual studio.
The app I published on playstore as "controltowerlive" ; this works in debug but on release I just get a white screen.
Further more, I also registered with AppCenter for analytics (there are no crashes) and my trace events work fine on Debug but never show up in Release.

Can anyone please suggest what I should try -- its the "hello world" application of Xamarin Forms.

Any pointers would help

Getting different instances while resolving from container

$
0
0

I have a specific platform service which is being registered using a platform initializer

 public class AndroidInitializer : IPlatformInitializer
    {
        public void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterInstance<IBlueToothService>(new BlueToothService_Android());
        }
    }

As you see I am registering an instance as I want it to be the same instance.
My main page VM get this service injected in its constructor:

public MainPageViewModel(INavigationService navigationService, IBlueToothService btService)
           : base(navigationService)
        {
             RefreshBlueTooothDevicesCommand = new DelegateCommand(RefreshBlueToothExecuted, RefreshBlueToothCanExecute);
            _blueToothService = btService;
            _blueToothService.DeviceAdded += BlueToothServiceDeviceAdded;
            _blueToothService.ScanFinished += () => ToggleRunningState();
        }

I am using this service also in a broadcast receiver:

 public override void OnReceive(Context context, Intent intent)
        {            
           IBlueToothService service = Xamarin.Forms.DependencyService.Get<IBlueToothService>();
            string action = intent.Action;
            if (action == BluetoothDevice.ActionFound)
            {
                BluetoothDevice newDevice = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
                service.AddDevice(new Models.BluetoothDevice(newDevice.Name, newDevice.Address));
            }
            if(action == BluetoothAdapter.ActionDiscoveryFinished)
            {
                service.RaiseScanFinishedEvent();
            }
        }

I am not getting the same instance. but 2 different ones. I am pretty sure that each one of them resolves them from a different container but I cant figure our how to point all of them to the same one.

Thanks.

Detect a person's anthropometric measurements with the camera

$
0
0

Hello, I have to develop an app that has to detect a person's anthropometric measurements with the camera.
Can uou help me? Thanks.

cant install Xamarin.GooglePlayServices.27.0.0

$
0
0

Im trying to update to the latedst versions of te Xamarim paCKAGES.

However Xamarin.GooglePlayServices.27.0.0 wont install.

Ive already installed the latest versions of every other Xamarin package, 2.0.0.6482, etc.

Below is the output from the package manager:

Attempting to gather dependencies information for package 'Xamarin.GooglePlayServices.27.0.0' with respect to project 'AndroidApplication1', targeting 'MonoAndroid,Version=v6.0'
Attempting to resolve dependencies for package 'Xamarin.GooglePlayServices.27.0.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Xamarin.GooglePlayServices.27.0.0'
Resolved actions to install package 'Xamarin.GooglePlayServices.27.0.0'
Attempting to gather dependencies information for package 'Xamarin.GooglePlayServices.27.0.0' with respect to project 'App2.Android', targeting 'MonoAndroid,Version=v4.4'
Attempting to resolve dependencies for package 'Xamarin.GooglePlayServices.27.0.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Xamarin.GooglePlayServices.27.0.0'
Resolved actions to install package 'Xamarin.GooglePlayServices.27.0.0'
Removed package 'Xamarin.GooglePlayServices.25.0.0' from 'packages.config'
Successfully uninstalled 'Xamarin.GooglePlayServices.25.0.0' from AndroidApplication1
Install failed. Rolling back...
Package 'Xamarin.GooglePlayServices 27.0.0.0' does not exist in project 'AndroidApplication1'
Package 'Xamarin.GooglePlayServices.25.0.0' already exists in folder 'E:\MSIV2012\Assemblies\Packages'
Added package 'Xamarin.GooglePlayServices.25.0.0' to 'packages.config'
Package 'Xamarin.GooglePlayServices 27.0.0.0' does not exist in folder 'E:\MSIV2012\Assemblies\Packages'
Could not install package 'Xamarin.GooglePlayServices 27.0.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========

The last line of the above gives the error I'm getting:

Could not install package 'Xamarin.GooglePlayServices 27.0.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.


The type or namespace name 'Gms' does not exist in the namespace 'Android'

$
0
0

"(are you missing an assembly reference?)"

I'm a long time Java/Android developer trying now to get a mapping app working in Xamarin. I found the following post which seems to be on point, but didn't help me:

https://forums.xamarin.com/discussion/6777/google-map-v2-didnt-find-class-com-google-android-gms-maps-mapfragment

I have the "Google Play Services" SDK installed. I have added a component "Google Play Services - Maps", yet i cannot compile my Map activity because of the following:

**
using Android.Gms.Maps;
using Android.Gms.Maps.Model;
**
looking at the samples i see under "References": Xamarin.GooglePlayServices.Base, Xamarin.GooglePlayServices.Basement, Xamarin.GooglePlayServices.Maps. How did they get there??? since i have a component (which the sample does NOT have...do i need these References?

help!!!!

Sharapie tool does not generate C# code properly.

$
0
0

Hi Folks,

I want to print receipts using EPSON TM-T88V thermal POS printer through mobile on Android and iOS platform.
For Android, I downloaded EPSON SDK from here.
For iOS, I downloaded it from here.

Epson SDK for android contains two .jar files named ePOS2.jar and ePOSEasySelect.jar and two libraries with extension .so named libepos2.so and libeposeasyselect.so which were referenced to Xamarin.Android project successfully, printing receipts on android went well.

For iOS, I refereed this walk-through on Xamarin documentation.

I used the following command to generate the c# files where my header and binary files were located:

sharpie bind --output=ePOS --namespace=ePOS --sdk=iphoneos12.0 *.h -scope ePOS

The generated files have too many syntax errors, which I don't know how to resolve at the moment. Below is the Structs.cs file with errors like "Identifier expected".

public struct
{
    [FieldOffset(0)]
    public long double __f;

    [FieldOffset(0)]
    public ulong __u;
}

Kindly help, and suggest whether I'm going in right direction.

Resource Dictionary for UWP/macOS and fonts

$
0
0

Hi guys,
I want to use a custom font for my app. I copied the font files in:

  • iOS: under Resources - Build Action BundleResource / Copy to Output Directory: Do not copy
  • Android: under Assets - Build Action Androd Asset / Copy to Output Directory: Do not copy
  • UWP: under Assets/Fonts - Build Action Content / Copy to Output Directory: Do not copy

I have two problems here. First is the UWP error:

Position 11:25. No property, bindable property, or event found for 'UWP', or mismatching type between value and property

The second is how to show my custom font.

Visual Studio 2017

Upgrade Xamarin.Forms to 3.2.0.839982 Broke build Value cannot be null. Parameter name: type

$
0
0

Hi

Unfortunately, the latest forms update has totally broken my project (thankfully I have a backup). It seems that every time I update forms it breaks my application in some way.

I have tried the various suggestions online such as deleting obj and bin folders for the project and, and removing the [XamlCompilation(XamlCompilationOptions.Compile)] from the code-behind, to no avail. Still wont build.

Anyone have any idea how to solve this - I am guessing it has effected like everyone using forms...

App.xaml : error : Value cannot be null.
3>App.xaml : error : Parameter name: type
3>PopupViews\PopupErrorPage.xaml : error : Value cannot be null.
3>PopupViews\PopupErrorPage.xaml : error : Parameter name: type
3>PopupViews\PopupPatientEventActivitySelector.xaml : error : Value cannot be null.
3>PopupViews\PopupPatientEventActivitySelector.xaml : error : Parameter name: type
3>PopupViews\PopupPatientEventCompletedViewer.xaml : error : Value cannot be null.
3>PopupViews\PopupPatientEventCompletedViewer.xaml : error : Parameter name: type
3>PopupViews\PopupPatientEventList.xaml : error : Value cannot be null.
3>PopupViews\PopupPatientEventList.xaml : error : Parameter name: type
3>PopupViews\PopupPatientEventSymptomSelector.xaml : error : Value cannot be null.
3>PopupViews\PopupPatientEventSymptomSelector.xaml : error : Parameter name: type
3>Views\AppDormantPage.xaml : error : Value cannot be null.
3>Views\AppDormantPage.xaml : error : Parameter name: type
3>Views\ConnectionStatusPage.xaml : error : Value cannot be null.
3>Views\ConnectionStatusPage.xaml : error : Parameter name: type
3>Views\PatientEventPage.xaml : error : Value cannot be null.
3>Views\PatientEventPage.xaml : error : Parameter name: type
3>XamlControls\ProteusConnectionStatusControl.xaml : error : Value cannot be null.
3>XamlControls\ProteusConnectionStatusControl.xaml : error : Parameter name: type
3>XamlControls\SpacelabsLogoControl.xaml : error : Value cannot be null.
3>XamlControls\SpacelabsLogoControl.xaml : error : Parameter name: type

Could not install package 'Xamarin.Android.Support.Compat 24.2.1'

$
0
0

Could not install package 'Xamarin.Android.Support.Compat 24.2.1'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Viewing all 204402 articles
Browse latest View live


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