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

Advertising or promotion in anywhere with android

$
0
0

I'm developping an application and i'd like to send advertising for all device with android near by store. For example, i have a store and when anybody is near this device receive an advertising or promotion from that store. I'd like in the radius of 500m~800m. Or client download this app, install and receive this advertising when is near store, but first option for me is better.


Error during release build

$
0
0

Unerwarteter Fehler bei der LinkAssemblies-Aufgabe.
Mono.Linker.MarkException: Error processing method: 'Android.Views.ScaleGestureDetector Xamarin.Forms.Platform.Android.GestureManager::InitializeScaleDetector()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.View.ScaleGestureDetectorCompat::SetQuickScaleEnabled(Android.Views.ScaleGestureDetector,System.Boolean)
bei Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
bei Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
bei Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
--- Ende der internen Ausnahmestapelüberwachung ---
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
bei Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
bei Mono.Linker.Steps.MarkStep.Process()
bei MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
bei Mono.Linker.Pipeline.Process(LinkContext context)
bei MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Retailer.Android

Hello,
my code shows this error trying to build a release version.

Can someone explain me what
s happend?

Turn off control rendering in Previewer

$
0
0

We use Lottie animations and some other third part controls that Xamarin Forms Previewer doesn't understand so I get the "There was a problem rendering this document" error. Is there a keyword or something I can put in the control to tell the previewer to just ignore it? It would be nice if there was a flag such as Preview="false"

No resources found that matches at AndroidManifest.xml

$
0
0

Hello,

I am trying to follow this solution https://stackoverflow.com/questions/41524459/broadcast-receiver-not-working-after-device-reboot-in-android but I get the following error:
**
No resource found that matches the given name (at 'resource' with value '@xml/my_accessibility_service').**

with my_accessibility_service.xml :

<?xml version="1.0" encoding="utf-8" ?>
    <accessibility-service
      xmlns:android="http://schemas.android.com/apk/res/android"
        android:packageNames="myapp"
        android:accessibilityFeedbackType="feedbackSpoken"
        android:description="@string/service_desc"
        android:notificationTimeout="100">
    </accessibility-service>

Why is it happening?
Thanks

Picker popup is shown twice when calling focus()

$
0
0

Hello

I've an issue when a Picker (in my example an ExtendedPicker, but it also happens with a normal Picker). In some cases (see below), when calling Picker's focus() method, the popup opens twice in Android simulator (not sure about iOS/real device).

In my case I've got a ListView with a Picker on each item. They work as long as I don't delete an item. After I deleted an item, on some still existing items when opening Picker, it's opened twice.

To reproduce the problem, you can load the project from here: https://github.com/skurth/App1

1) Start app
2) Delete group "Tübach City" by pressing "Delete" button next to it.
3) Press on one of the three "Kopf" buttons from group "PSW Tübach" (not from group "1. FC Schwangere Bergente", there still one popup opens correctly). They open a picker.
4) Press OK on the opened Picker.
5) Another picker popup is shown. Why?

Is there something I do wrong or is it a bug?
Relevant code is in file "ItemCell.cs", starting from line 39.

(The reason why I set picker IsVisble=false and using a button instead of the standard picker label is because I need to customize font etc., and this way it's easier than writing a custom renderer for Picker.)

dependency service BroadcastReceiver send data back

$
0
0

hi,
what is the best way to send data back from the dependency service Broadcastreceiver (android) within the OnReceive method?
i used this project https://github.com/angelcalvasp/Blacksun.XamForms to build an dependency service for scanning BT devices. however, this project is not finished yet.

_bluetoothClient = DependencyService.Get();

public interface IBluetoothScanner
{
void StartDiscovery();

    void EndDiscovery();
}

public async Task SearchDevices()
{
_bluetoothClient.StartDiscovery();
await Task.Delay(TimeSpan.FromMilliseconds(10000));
_bluetoothClient.EndDiscovery();
}

public void StartDiscovery()
{
btAdapter.StartDiscovery();
}

    public void EndDiscovery()
    {
        btAdapter.CancelDiscovery();
    }

     broadcastReceiver = new CustomBroadcastReceiver();
            CurrentActivity = (Activity)Forms.Context;
            IntentFilter filter = new IntentFilter();
            filter.AddAction(BluetoothDevice.ActionFound);
            filter.AddAction(BluetoothAdapter.ActionDiscoveryStarted);
            filter.AddAction(BluetoothAdapter.ActionDiscoveryFinished);
            CurrentActivity.RegisterReceiver(broadcastReceiver, filter);

public class CustomBroadcastReceiver : BroadcastReceiver
{
public event EventHandler DeviceDiscoveryStarted;

    public event EventHandler DeviceDiscoverEnded;

    public event EventHandler<DeviceFoundEventArgs> DeviceDiscovered;

    public CustomBroadcastReceiver()
    {

    }

    public override void OnReceive(Context context, Intent intent)
    {

        String action = intent.Action;

        if (BluetoothAdapter.ActionDiscoveryStarted.Equals(action))
        {
            DoDeviceDiscoveryStarted();
        }
        else if (BluetoothAdapter.ActionDiscoveryFinished.Equals(action))
        {
            DoDeviceDiscoverEnded();
        }
        else if (BluetoothDevice.ActionFound.Equals(action))
        {

        //SEND DATA BACK TO FORMS
            System.Diagnostics.Debug.WriteLine("Found a device");
            BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
            //DoOnDeviceDiscovered(device.GetPairableBluetoothDevice());

        }
    }
}

thanks

Present UIImagePickerController from pagesheet modal jumps layout iOS 12

$
0
0

When present the iOS UIImagePickerController from an Pagesheet Modal in iOS 12, the modal jumps to the left top of the screen. When cancelling or taking a photo, the modal layout jumps back to it's original position. This problem started since iOS 12.

Does anyone have a fix for this problem? Or knows what this problem causes?

Before taking a photo:

When taking a photo (when UIImagePickerController showed):

What are the considerations to officially support webassembly/HTML5?

$
0
0

Considering the dawn of Xamarin Forms 4.X and the latest news on Connect() (open sourcing all relevant MS UI frameworks, but not accepting pull requests for any cross platform initiative) I think it's fair to ask these questions:

Are there any considerations to support webassembly/HTML5 as an official platform for Xamarin Forms?

  • If so, could you please elaborate on these considerations?
  • If no, could you please share the reasons which prevented MS from making XF available on webassembly/HTML5?

Note: I'm well aware of Ooui. However, with deep respect for the author and without any offense nor intention to discount his work I have to state:

  • there was not much activity on that project recently
  • after all that project is not 'backed up' by MS
    Hence, I could not consider it being at the same level as any potential, official support of Xamarin Forms for webassemblyHTML5

How to create shared frame layout to reuse it in other xaml pages!

$
0
0

I want to create a shared control to use this structure of frame inside my other xaml files:

<Frame
Padding="1"
BackgroundColor="Black
CornerRadius="7"
HasShadow="False">

                <Frame
                    Margin="2"
                    Padding="5"
                    BackgroundColor="White"
                    CornerRadius="5"
                    HasShadow="False">
    </Frame>

//My Other xaml control goes here.

</Frame

My doubt is how i can create this structure of frames in seperate xaml file to reuse it other xaml files!!

Better way to select multiple photos from gallery in Android and iOS

$
0
0

Hi, i'm trying to find a solution to select multiples photos in Xamarin in both platforms, can be two separated nugets or something like that.
I tried GmImagePicker, but it simply don't open the images selector view controller, i followed the GitHub tutorial.
Something i can use? Thanks.

Xamarin Forms (Android) StartForegroundService not work (App crash)

$
0
0

The xamarin forms should be started with StartForegroundService service on Android 8.0 versions as it is known for doing a bacgroudservice.

But my service does not start and my application is crashing.

My Code :

var intent = new Android.Content.Intent(this, new ServiceScreen().Class); if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { StartForegroundService(intent); } else { StartService(intent); }
My ServiceScreen.cs:

public override IBinder OnBind(Intent intent) { return null; } public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { try { IntentFilter filter = new IntentFilter(); filter.AddAction(Intent.ActionScreenOn); filter.AddAction(Intent.ActionScreenOff); BroadcastReceiver broadcast = new receiverScreen(); RegisterReceiver(broadcast, filter); } catch (Exception e) { Log.Debug("Hata", e.ToString()); } return StartCommandResult.Sticky; } public override void OnDestroy() { base.OnDestroy(); var broadcastIntent = new Android.Content.Intent(this, typeof(RestarterBroadcastReceiver)); SendBroadcast(broadcastIntent); } }

My receiverScreen.cs

`[BroadcastReceiver]
public class receiverScreen : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{

    if (intent.Action.Equals(Intent.ActionScreenOn))
    {
        Toast.MakeText(context, "On Screen", ToastLength.Long).Show();
        Log.Debug(TAG, "-------------- on !");
    }
    else if (intent.Action.Equals(Intent.ActionScreenOff))
    {
        Toast.MakeText(context, "Off Screen", ToastLength.Long).Show();
        Log.Debug(TAG, "-------------- off !");
    }
}

}`

My App Output

12-08 10:58:09.089 E/ActivityThread(13002): Service md5108cbe39ce2243540ccf5f375034c930.ServiceScreen has leaked IntentReceiver com.xxx.xxx.receiverScreen@14a30de that was originally registered here. Are you missing a call to unregisterReceiver()? 12-08 10:58:09.089 E/ActivityThread(13002): android.app.IntentReceiverLeaked: Service md5108cbe39ce2243540ccf5f375034c930.ServiceScreen has leaked IntentReceiver com.xxx.xxx.receiverScreen@14a30de that was originally registered here. Are you missing a call to unregisterReceiver()? 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.LoadedApk$ReceiverDispatcher.(LoadedApk.java:1351) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1132) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1421) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1394) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1382) 12-08 10:58:09.089 E/ActivityThread(13002): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:609) 12-08 10:58:09.089 E/ActivityThread(13002): at md5108cbe39ce2243540ccf5f375034c930.ServiceScreen.n_onStartCommand(Native Method) 12-08 10:58:09.089 E/ActivityThread(13002): at md5108cbe39ce2243540ccf5f375034c930.ServiceScreen.onStartCommand(ServiceScreen.java:39) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3474) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ActivityThread.-wrap20(Unknown Source:0) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692) 12-08 10:58:09.089 E/ActivityThread(13002): at android.os.Handler.dispatchMessage(Handler.java:106) 12-08 10:58:09.089 E/ActivityThread(13002): at android.os.Looper.loop(Looper.java:164) 12-08 10:58:09.089 E/ActivityThread(13002): at android.app.ActivityThread.main(ActivityThread.java:6494) 12-08 10:58:09.089 E/ActivityThread(13002): at java.lang.reflect.Method.invoke(Native Method) 12-08 10:58:09.089 E/ActivityThread(13002): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 12-08 10:58:09.089 E/ActivityThread(13002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 12-08 10:58:09.466 I/zygote (13002): Thread[3,tid=13008,WaitingInMainSignalCatcherLoop,Thread*=0xa6b4ec00,peer=0x12d41350,"Signal Catcher"]: reacting to signal 3 12-08 10:58:09.466 I/zygote (13002): 12-08 10:58:09.505 I/zygote (13002): Wrote stack traces to '[tombstoned]' 12-08 10:58:10.378 D/AndroidRuntime(13002): Shutting down VM 12-08 10:58:10.381 E/AndroidRuntime(13002): FATAL EXCEPTION: main 12-08 10:58:10.381 E/AndroidRuntime(13002): Process: com.xxx.xxx, PID: 13002 12-08 10:58:10.381 E/AndroidRuntime(13002): android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground() 12-08 10:58:10.381 E/AndroidRuntime(13002): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768) 12-08 10:58:10.381 E/AndroidRuntime(13002): at android.os.Handler.dispatchMessage(Handler.java:106) 12-08 10:58:10.381 E/AndroidRuntime(13002): at android.os.Looper.loop(Looper.java:164) 12-08 10:58:10.381 E/AndroidRuntime(13002): at android.app.ActivityThread.main(ActivityThread.java:6494) 12-08 10:58:10.381 E/AndroidRuntime(13002): at java.lang.reflect.Method.invoke(Native Method) 12-08 10:58:10.381 E/AndroidRuntime(13002): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 12-08 10:58:10.381 E/AndroidRuntime(13002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Unhandled Exception:

Android.Util.AndroidRuntimeException:

Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found

$
0
0

Already found the same problem here.

My error:

Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found

The solution on that thread is downgrade the xamarin forms to version 2.5.1.527436 in all the projects. But I can't do that in my project, because I am using some features that are available in latest xamarin forms like android bottom tab feature, autosize property of editor and flowdirection property of listview.

I have this problem after updating xamarin forms to 3.4.0.1008975 from 2.5.0.121934. Problem is only on the UWP part. Android and IOS apps are working fine.

Error lines:

var rendererAssemblies = new List<Assembly>
   {
       typeof(ImageCircleRenderer).GetTypeInfo().Assembly
   };
rendererAssemblies.AddRange(Rg.Plugins.Popup.Popup.GetExtraAssemblies());
Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e, rendererAssemblies);

So how can I fix this issue without degrading the xamarin forms?

Icons have poor clarity in Xamarin forms UWP project

$
0
0

I am using 24x24 pixels icons in my xamarin forms UWP project, but not getting good clarity when it comes in UI. For Android, I am using 4 set of icons for different devices and 3 set for IOS. How many sets of icons are needed for UWP and what is the resolution for those icons?

VS2017 15.9 & XF 3.4 - can't build the project

$
0
0

Hi,

I am trying to build a XF project but getting the following weird error:

3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void WiFiManager.MainPage::InitializeComponent()' in assembly: 'WiFiManager.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Xaml.Internals.SimpleValueTargetProvider::.ctor(System.Object[],System.Object,Xamarin.Forms.Internals.INameScope)

The full list is available here:
https://pastebin.com/k4hTDVTQ

What am I doing wrong?

How to convert the all content in scroll view to Bitmap in Xamarin forum

$
0
0

Hi,

I have converted the current view to bitmap in Xamarin Forms dependency service, which is working fine with the below code snippet. Kindly share the instruction on how to convert the all content in scroll view (include the non-display contents) to Bitmap.

Android:

        public async System.Threading.Tasks.Task<byte[]> CaptureAsync()
        {
            var activity1 = Forms.Context as Activity;          

            var view = activity1.Window.DecorView;
            view.DrawingCacheEnabled = true;

            Bitmap bitmap = view.GetDrawingCache(true);

            byte[] bitmapData;

            using (var stream = new MemoryStream())
            {
                bitmap.Compress(Bitmap.CompressFormat.Jpeg, 0, stream);
                bitmapData = stream.ToArray();
            }

            return bitmapData;
        }

iOS:

public async System.Threading.Tasks.Task<byte[]> CaptureAsync()
        {
            var view = UIApplication.SharedApplication.KeyWindow.RootViewController.View;

            UIGraphics.BeginImageContext(view.Frame.Size);
            view.DrawViewHierarchy(view.Frame, true);
            var image = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            using (var imageData = image.AsJPEG(100))
            {
                var bytes = new byte[imageData.Length];
                System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, bytes, 0, Convert.ToInt32(imageData.Length));
                return bytes;
            }

        }

Thanks,


Xamarin Forms Accordion Add Another Tab

Xamarin Forms - Chromebook support

$
0
0

I have a Xamarin Forms application that works fine on standard Android devices, but will not install on Chromebook. After much fruitless searching, hacking the Chromebook into developer mode, trying to sideload the app, it will finally install but crashes immediately when run. The message indicated on the Google Play Store is "this device isn't compatible with this version". Am I missing something?

Shadow CustomRenderer for iOS dismisses cornerRadius?

$
0
0

Hi, I have found this custom renderer for making shadows on a frame look better, but...

When using the custom renderer I do not have the option for rounded corners anymore.

How do I accomplish both?

    [assembly: ExportRenderer(typeof(Frame), typeof(MaterialFrameRenderer))]
    namespace md.iOS.CustomRenderers
    {
        public class MaterialFrameRenderer : FrameRenderer
        {
            public override void Draw(CGRect rect)
            {
                base.Draw(rect);

                // Update shadow to match better material design standards of elevation
                Layer.ShadowRadius = 2.0f;
                Layer.ShadowColor = UIColor.Gray.CGColor;
                Layer.ShadowOffset = new CGSize(2, 2);
                Layer.ShadowOpacity = 0.80f;
                Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
                Layer.MasksToBounds = false;
            }
        }
    }

Hoping for help and thanks in advance :-)

How to create separator line right after tabbed menu?

$
0
0

I am using tabbed page in my project. What i wanted to do is to insert separator line just below the tabbed menu. My content page contents are scrollable and don't wanted the separator line to scroll with the page. Is there any way to achieve the such thing.?

ModernHttpClient errorhandling in PCL

$
0
0

When i'm using a HttpClient with a NativeMessageHandler, an UnknownHostException is thrown when there is no wifi (on Android).
Is there a way to catch this exception so it works on Android and iOS because i can't use the Java.Net library?

Viewing all 91519 articles
Browse latest View live


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