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

Launching application from android local notification

$
0
0

Hello,

I'm trying to launch the application when the user taps a local notification. To accomplish this, we need to set the ContentIntent to the notification, and that start's the desired activity set at the intent.

Here's some code:

Intent mainActivityIntent = new Intent(context, typeof(MainActivity)); PendingIntent mainActivityPendingIntent = PendingIntent.GetActivity(context, 0, mainActivityIntent, PendingIntentFlags.NoCreate); Notification.Builder builder = new Notification.Builder(context) .SetContentTitle("Atenção").SetContentText(texto) .SetSmallIcon(Resource.Drawable.icon); Notification notification = builder.Build(); notification.ContentIntent = mainActivityPendingIntent;

The problem is, when the user taps, if the application is already loaded, a new instance of the application is created. I tried to re-use an instance of the Application but the same problem happens.

Could somebody help me?


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.

UWP InAppNotification in Xamarin.Forms?

$
0
0

Hello,

I have a Xamarin.Forms App and I want to show in app notifications (about loading progress etc.). I use Toast.MakeText for Android and for UWP I would like to use the InAppNotification from the UWP community toolkit. This is obviously a UWP XAML control which I cannot add to my Xamarin.Forms pages.

Can I somehow add this control from an Interface (which allows me to use UWP controls) to my current page? I use Interfaces to generate custom popups for each platform, but I did not find an option to add a UWP XAML Control to the current page.

Regards,

Philipp

iPhone simulators missing from debug device list

$
0
0

I am running Visual Studio 15.9.5 on Windows 10, I have a MacBook Pro with Visual Studio for Mac and all the latest updates, with Xcode 10.1.

In Xcode Preferences/Components, you can see I have installed iOS 10.0 Simulator, 10.1,10.2,10.3.1,11.0,11.1,11.2, 11.3, 11.4, 12.0.

While paired up with the MacBook Pro, in DEBUG mode, I can see all the iPhone 5 and 6's from 10.3 to 12.1 (I am targeting 10.3).
However, in this list, there are no iPhone 7's or above. In the unsupported list, it does some some iPHone 7's, but they are older than 10.3.

Does anyone have some suggestions as to how I can fix this?

Xamarin.Forms app does not run after released to "TestFlight"

$
0
0

My Xamarin.Forms app runs fine on emulators, and I can connect an iPhone 5 to my MacBook and successfully debug and run the app on a physical phone in debug mode. However, after pushing the release to "TestFlight", the app appears to start with the splash screen, then just disappears.

In my AppDelegate.cs in "FinishedLaunching", i wire up for unhandled exceptions like this:

        AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
        TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;

Then, from within these handlers, I report crashes to my own backend log system, but also I have code to record the crash with App Center's "Crashes.TrackError()". I have verified this works by creating a test page that generates unhandled exceptions, and it successfully is caught with my error handlers and reported to the server.

When I run the app from TestFlight, the app crashes immediately, and no log information is sent to my log system, or to App Center. This is my nightmare scenario in support phones, crashes that I have no details about.

Can you please share any suggestions or ideas you may have, on how I can go about solving this crash problem; or how I can get diagnostics information from this crash, and future crashes.

Thanks.

How to add buttons into the renderer map pin?

$
0
0

Is it possible to add some buttons into the rendered map pin and every button can trigger its associated event? If so, how to do it?

Possible to automate switching icons for Xamarin.Forms project?

$
0
0

Hi,

We have a single project that is used by 2 different clients. The Apple store won't let us use the same icon for both, so we need to build version A with Icon set A, and then the same code as version B but with Icon B. Do you see any way to automate switching the icons?

Thanks!!
jesse

Xamarin.Form Image not showing in Imagecell

$
0
0

Hi i have seen some form where people having problem with picture not showing up when they add them to the ImageCell
I even print out my image string so i can look if something is wrong.
If i go back some versions of Xamarin.Form the http... links works but still not the image on the device. Newest version is from (24 Jan 2019)

The image shows if i do this...



<ListView.ItemTemplate>



</ListView.ItemTemplate>

The images is in default project (not android / ios) and i have a folder called Product there. and this works
_MainLayout.Children.Add(new Image { Source = ImageSource.FromResource("Inkopslista.Product.1.jpg") });

is this a problem, do i need to have them in andorid drawings to get the Imagecell to work?


Does it possible customize the pin event of Map to reduce tap times

$
0
0

After Xamarin Form Map shows a map on an Android or iOS device, and tap a map pin, it will show the callout of the pin and tap this callout, it just triggers the pin's clicked event, i.e., two tap actions are required to trigger the pin event. Is it possible let Xamarin Form Map to trigger an event which can do something when tap the pin, i.e., one tap action can trigger an event which is associated the tapped pin by rendering Xamarin Map (for both Android and iOS)? If so, how to do it?

The link doesn't give any hint for my question
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map/customized-pin

Background and Foreground app and Push Notifications.

$
0
0

Hello developers,

I'm using the plugin https://github.com/CrossGeeks/FirebasePushNotificationPlugin and https://github.com/winstongubantes/MatchaBackgroundService

The plugin work good, I receive the push notification with background, Foreground and too when the app is closed.

The problem is that plugin FirebasePushNotification, with event OnNotificationReceived detect the event when app is background but don't enters the event, without de event OnNotificationReceived, all it works good! when I receive the push notifacion with mi app the background and I have other code, for example show alert and back the app foreground it works!, the alert it's visible.

I need the following:

My app don't' use commercial, only professional.

When receive push notification and my app is foreground, show alert (it works), when my background app receive push notification with de plugin, show alert (when back foreground app).

Any examples?
Where find information?

Thanks advance.

Problem with Absolute Layout and Overlay Areas

$
0
0

Hi there!

I have a View with list view and, using absolute layout, I created an editor for that list view.

The editor, when visible, overlays itens 2 to 6.

I can tap or press itens 1 and 7 to call the editor.

If I tap itens 2 to 6, nothing happens. The editor, even invisible, block my selection.

Is there a way to fix this problem?

Thanks in advance for any kind of help.

Regards,

Ciro.

Xamarin UWP APP problem.

$
0
0

Ive been running with my xamarin forms app on android for some time and I need to also test the UWP version.

I'm getting the following error:

The "WireUpCoreRuntime" task was not given a value for the required parameter "CoreRuntimeSDKLocation"

Any Ideas?

Options for video playback

$
0
0

What are my options for video playback in Xamarin.forms? Searching through the forums, webview seems to be the suggestion alot, but I hate the fact that an app needs to be clunky with an 'iframe' of sorts. Is there a native player that I can use to play YouTube/Vimeo videos directly in both a mini as well as expanded view?

How To Store User Session To Stay Logged In

$
0
0

Hi everyone. How can i store the user session data to stay logged in?

Thanks!

Can I use Xamarin Forms to build an Android 6.0 application?

$
0
0

Hi,
I'm trying to build a Xamarin Forms application to run in an Android 6.0 android box, but I'm always getting the error while compiling:

Package Xamarin.Android.Support.v7.CardView 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.CardView 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)

Is there any way to get the package for Android Version 6.0?

Thanks,

L. Pinho


[ADVANCED ]Xamarin Bindings to Canon EOS SDK - issues

$
0
0

Hi!

Official Android native library for Canon EOS digital cameras however exists, but an SDK for Android was not (yet?) published by Canon company.
The native library (name is libEDSDKCore.so) can be easily extracted from either Canon Camera Connect or EOS Remote applications.

The list of SDK methods, structures and constants in the EDSDKCore library is attached to this post (EDSDKCore.java.txt - got this file after some reverse engineering).

I started to create a Xamarin C# wrapper class around the library, so far the following methods:

using System;
using System.Runtime.InteropServices;

namespace CCApp {
    public class EDSDKWrapper {
        [StructLayout(LayoutKind.Sequential)]
        public struct EdsDeviceInfo {
            public int DeviceCode;
            public string DeviceName;
            public int ProductID;
            public string SerialNumber;
        }

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsInitializeSDK();

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsTerminateSDK();

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsRelease(IntPtr target);

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsGetCameraList(out IntPtr CameraList);

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsGetChildCount(IntPtr CameraRef, out int Count);

        [DllImport("EDSDKCore", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
        public static extern int EdsGetChildAtIndex(IntPtr CameraRef, int Index, out EdsDeviceInfo DeviceInfo);

    }
}

Problem is at the test app where I called some of above methods.
My app detects the camera (Canon EOS 1300D) connected to smartphone via USB cable, I can also query some general USB information.
Return values of all above methods are OK (=0) but the EdsGetChildCount returns always 0 in the Count parameter and I have no idea why.

Example code:

// prerequisite#1: a Canon EOS camera connected via USB cable to smartphone
// prerequisite#2: UsbManager instance initialized, UsbDevice instance referencing the camera created
// prerequisite#3: .OpenDevice(dev) method called on UsbManager instance
var r0 = EDSDKWrapper.EdsInitializeSDK();                                 // r0 should be 0
var r1 = EDSDKWrapper.EdsGetCameraList(out IntPtr camList);            // r1 should be 0
var r2 = EDSDKWrapper.EdsGetChildCount(camList, out int c);            // r2 should be 0; c should be 1 -- here is the problem, it is always zero
var r3 = EDSDKWrapper.EdsRelease(camList);                           // r3 should be 0
var r4 = EDSDKWrapper.EdsTerminateSDK();                            // r4 should be 0

Either the wrapper methods or the calls are incorrect but the connected camera count is always zero.
Any help on this would be appreciated!

Best Regards,

Ladislav

Consume System.Drawing.Common package in Xamarin Android app?

$
0
0

My rendering code is now ported to .Net Standard 2.0 assemblies for portability.
Next step is to consume said assemblies in a Xamarin Android app.

However I do not seem to be able to consume for example the System.Drawing.Graphics type in my Xamarin code, even though I have added a reference to the System.Drawing.Common package.

Am I attempting the impossible? Must anything System.Drawing.Common be completely encapsulated in my .NET Standard assemblies? Or is there a viable workaround?

Calling a Command on Parent from Child

$
0
0

I have a Page:

 <ContentPage  x:Name="MyPage">

The Page references an external xaml via a resource

<ResourceDictionary Source="SomeTemplate.xaml"></ResourceDictionary>

All is fine, but in the external xaml I am trying to reference a **MyPage ** command, but **MyPage ** can't be found - the compiler throws an errors.

<SomeControl TappedCommand="{Binding Source={x:Reference MyPage}, Path=BindingContext.SomeCommand}">

Question about Xamarin

$
0
0

Hello guys, I am new in this domain and I want to ask you how can I start to make an android app using Xamarin? I had the VS 2013 installed because I used it (we learn the C# at our school) and I understood that for creating android apps I need to install the Visual Studio 2017. I installed it and uninstalled several times because I simply did not understand how can I start the project.
When I select New proect -> Android -> Android App (Xamarin), there is already something written in the project .cs and it contains a lot of errors. And more than that, I don't find the "Main.axml" how I saw on youtube at guys that were making simple apps. Instead of it, I have "activity_main.axml" and "content_main.axml".
Other thing I saw on youtube was that the guys when they clicked New Project and Android, they had a lot of possibilities to choose from, including "Blank App (Android)", and I don't have that. I have only 5 possibilities:

i.imgur.com/B8y6dQG.png

So, can you help me to begin? I want you only to show me how to start the project.. :(
And, one more thing.. As I said earlier, I don't know a lot of Xamarin, but the process of creating apps is the same like the process of creating windows forms? (for instance) I mean at VS 2013 with drag&drop items on the designer tab, with properties of the elements, with events etc?

Missing required Icons

$
0
0

Hi,

we have a problem uploading our app to the iOS app store for some days now. Actually it is a Forms App but hope it's still correct in this forum.
The app was working before but since we updated to Mojave and updated some of the Xamarin stuff there seems to be problem in building the asset catalog.
When trying to upload the ipa to the app store we get errors like:

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '76x76' pixels, in .png format for iOS versions >= 7.0."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '167x167' pixels, in .png format for iOS versions supporting iPad Pro."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '152x152' pixels, in .png format for iOS versions >= 7.0."

We already deleted bin/obj folders. Recreated the asset catalog. Checked the path in info.plist.
Everything seems to be fine.

I could figure out that the Assets.car that is created in copied to the ipa is empty or includes a default Xamarin Forms image.
I checked my build output and there are two entries related to the Assets.car:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/actool/bundle/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

and later:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

This makes actually no sense to me. The first copies the correct file to the bin path with the related assets. The second seems to copy an empty template file. Does that make sense to anyone? Is it possible to change the build process or is the actool building incorrect?

Any help is appreciated.

Chris.

Viewing all 204402 articles
Browse latest View live


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