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

Is it possible to use BOTH a Notification Service Extension and Notification Content Extension?

$
0
0

For my application I am using a Notification Service Extension to modify the way the notification is displayed to the user.
I also want to display a photo in its content, for this I understand I would need to use a Notification Content Extension.

Is it possible to use both? I don't really see how that would be.

How can I add a photo in my notification and where would that photo need to reside? Can be it in the Library folder?


Open default email app

$
0
0

Hi guys,
how can I open the default app for email? I don't want to send anything, only open the default app.
Thanks

How to use NEW Upload Key to sign app update and upload to Google Play store?

$
0
0

Hi,

Somehow I managed to save the wrong keystore for my Android app that I developed using Xamarin and already published.
When I wanted to upload an update to the Google Play Store with the keystore that I thought was the right keystore,
the SHA certificate did not match.

Luckily I was registered for Google Play App Signing so they were able to reset the Upload Key for me.
In order to reset the upload key I:

  1. (dont know if i had to do this to generate new upload key) Generated a new archive and new keystore for the Android project in Xamarin and exported the APK to a folder. In that folder i ran the command lines in the next steps:

  2. Generated a new upload key using the command line:
    keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks

  3. Exported the certificate for that key to a *.pem file:
    keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks

  4. Sent the *.pem to Google Play Developer Support.**

    Now that I have a *.pem file and *.jks file, how do I create the new APK file for my Xamarin Android project, signed with the new upload key in Visual Studio?

Xamarin with Azure IoT Hub

$
0
0

May I know how to show or plot the graph of sensors data from Azure IoT hub by using Xamarin.Forms?

Scrolling issue on UICollectionView

$
0
0

I implemented UICollectionView on my project because the UI requires a card like display. The problem is, when I'm scrolling it I can't scroll it up to the last record. By the way, I put my UICollectionView on top of a UIView that is inside a UIScrollView. Scrolling horizontal on UIScrollView doesn't have any problem. Do I need to adjust the height of my UICollectionView? If yes, how can I achieve it?

The “LinkAssemblies” Task Failed Unexpectedly. Xamarin.Forms 3.4.0.1009999 Update

$
0
0

After updating to Xamarin.Forms 3.4.0.1009999, I get the following error when trying to run the application in release mode - The "LinkAssemblies" Task Failed Unexpectedly

I've searched this error and seen multiple threads on this issue but they were all previous versions of xamarin and non of the suggested solution seemed to work.

What I have tried though is:

  • Clearing bin and obj folders then rebuilding the solution.
  • Changing the linker behaviour (turning it off), which actually works but a huge application is not an option.
  • Tried cleaning and building, instead of rebuilding, which is essentially the same thing, it was worth a shot though, it worked for someone else previously
  • Deleting and re-adding the Xamarin.Forms package from the Xamarin.Android project
  • I expected the project to run on the device like it did on previous versions of Xamarin.Forms without having to change the linker behaviour and increase the size of the application significantly.

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.

Having trouble when import jar file into Android Studio

$
0
0

I want to import jar file into Android studio from Xamarin Android Class Library following the tutorial in Xamarin Getting Started in Android(I can't insert link here yet). I follow the exact same in the tutorial but I met problems when I import jar file into Android studio. aar file works.

These are the errors I met in android studio:

            E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.example.username.hello_from_csharp, PID: 3800
                java.lang.RuntimeException: Unable to resume activity ``````````````````{com.example.username.hello_from_csharp/com.example.username.hello_from_csharp.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.username.hello_from_csharp/hello_from_csharp.HelloActivity}; have you declared this activity in your AndroidManifest.xml?``````````````````
                    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3429)
                    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
                    at android.app.ActivityThread.-wrap12(ActivityThread.java)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                    at android.os.Handler.dispatchMessage(Handler.java:102)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                 Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.username.hello_from_csharp/hello_from_csharp.HelloActivity}; have you declared this activity in your AndroidManifest.xml?
                    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
                    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
                    at android.app.Activity.startActivityForResult(Activity.java:4225)
                    at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:68)
                    at android.app.Activity.startActivityForResult(Activity.java:4183)
                    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:751)
                    at android.app.Activity.startActivity(Activity.java:4522)
                    at android.app.Activity.startActivity(Activity.java:4490)
                    at com.example.khortsuming.hello_from_csharp.MainActivity.onResume(MainActivity.java:21)
                    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
                    at android.app.Activity.performResume(Activity.java:6783)
                    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)

I googled for the error and it says there should be a [Activity] attributes in Xamarin C#

        [Activity(Label = "HelloActivity"),
            Register("hello_from_csharp.HelloActivity")]
        public class HelloActivity : Activity
        {
            protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);

                SetContentView(Resource.Layout.hello);
            }
        }

The codes provided in the tutorial contains the Activity label.
Please help, thanks


Failed to read FormsViewGroup.dll with debugging symbols

$
0
0

So... this error started popping up when I try building as Release on Android.

Failed to read 'C:\Users\gferreira\Documents\Source\Repos\EcoMindMobile\EcoMind\EcoMind.Android\obj\Release\81\linksrc\FormsViewGroup.dll' with debugging symbols. Retrying to load it without it. Error details are logged below.

The details:

1>Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly
1>   at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader, Boolean throwIfSymbolsAreNotMaching)
1>   at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
1>   at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
1>   at Mono.Cecil.ModuleDefinition.ReadModule(Disposable`1 stream, String fileName, ReaderParameters parameters)
1>   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
1>   at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
1>   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.ReadAssembly(String file)

This same error repeats 3 times throughout the build (found in the build log with Diagnostic MSBuild settings).

It seems to be something related to Xamarin Forms itself and linking, though after more hours than I'd like to admit sinked into this, I have no idea how to solve it. It's just warning, and it builds/works despite this, however just disregarding the warning doesn't seem like the best idea.

I didn't change anything in the release configs or nuget packages, it just started appearing out of the blue last week when I archived the solution.

The seemingly classic mscorlob conflict also appears, though this one has been happening for longer (I've been ignoring it as there doesn't seem to be an actual fix?)

1>There was a conflict between "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" and "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
1>    "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" was chosen because it was primary and "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was not.

Could they be related? There are Xamarin.Forms references to both versions for some reason. Any ideas? I'm inclined to just start ignoring the warning, because so far things are still working.

how to display .gif image as launch screen(splash screen) in xamarin forms ios

$
0
0

how to display .gif image as launch screen(splash screen) in xamarin forms ios.i have idea in xamarin forms android but i don't have idea in ios.please share with me if any one have idea

Need to add item one by one in Activity2 on selecting item in Activity1(am using treeview)

$
0
0

Hi,
Can anyone please have a look at below code...

Am new to xamarin.android. Any help would be appreciable.

  public class EmptyActivity : Activity
    {
        public SfTreeView treeView1;
        public Intent intent;
        public EmptyActivity()
        {
      //main = new MainActivity();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.EmptyViewlayout);

            var linearLayout = FindViewById<Android.Widget.LinearLayout>(Resource.Id.emptylinearLayout);
             treeView1 = new SfTreeView(linearLayout.Context);
            treeView1.SelectionMode = SelectionMode.Multiple;
            treeView1.SelectionChanged += TreeView1_SelectionChanged; ;

            var india= new TreeViewNode() { Content = "Australia", IsExpanded = true };
            var maharashtra= new TreeViewNode() { Content = "New South Wales" };
            var delhi= new TreeViewNode() { Content = "Victoria" };
            var bengal= new TreeViewNode() { Content = "Queensland" };
            var karnataka= new TreeViewNode() { Content = "West Australia" };
            var tamilNadu= new TreeViewNode() { Content = "South Australia" };

            india.ChildNodes.Add(delhi);
            india.ChildNodes.Add(maharashtra);
            india.ChildNodes.Add(bengal);
            india.ChildNodes.Add(karnataka);
            india.ChildNodes.Add(tamilNadu);

            treeView1.Nodes.Add(india);

            linearLayout.AddView(treeView1);
        }

        private void TreeView1_SelectionChanged(object sender, ItemSelectionChangedEventArgs e)
        {
            var items = e.AddedItems;
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];
                if (item is TreeViewNode)
                {
                    TreeViewNode node = (TreeViewNode)item;
                    intent = new Intent(this, typeof(MainActivity));
                    if (node.ParentNode != null)
                    {
                        intent.PutExtra("ParentNode", node.Content.ToString());
                        StartActivity(intent);
                    }
                    else
                    {
                        intent.PutExtra("ChildNode", node.Content.ToString());
                        StartActivity(intent);
                    }
                }
            }
        }
    }

 public class MainActivity : AppCompatActivity
    {
        public SfTreeView treeView;
        public TreeViewNode newTreeviewNode;
        public TreeViewNode newChildNode;
        EmptyActivity EmpObject;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            EmpObject = new EmptyActivity();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            var linearLayout = FindViewById<Android.Widget.LinearLayout>(Resource.Id.linearLayout1);
            treeView = new SfTreeView(linearLayout.Context);
            treeView.SelectionMode = SelectionMode.Single;
            Button button = new Button(linearLayout.Context);
            button.Text = "Start activity";
            button.Click += delegate
            {
                StartActivity(typeof(EmptyActivity));
            };
            linearLayout.AddView(button);
            linearLayout.AddView(treeView);

        }

        protected override void OnResume()
        {
            string Node = Intent.GetStringExtra("ParentNode");
            string childNode = Intent.GetStringExtra("ChildNode");
            newTreeviewNode = new TreeViewNode() { Content = Node, IsExpanded = true };
            newChildNode = new TreeViewNode() { Content = childNode };

            newTreeviewNode.ChildNodes.Add(newChildNode);

            treeView.Nodes.Add(newTreeviewNode);

            base.OnResume();
        }
    }

In my above code am trying to add treeview node in MainActivity, one by one. But on each time when i select i only get one item in my Activity page.
can anyone suggest me how to make each item visible when selecting the treeview node in EmptyActivity page

Lottie in Xamarin forms android

$
0
0

Hi ,
I tried to work wih lottie , it works fine in ios but in android it does not show up .

I tried to add AnimationViewRenderer.Init() to main acitivity but it dosent work ! always dosnet know lottie .

does any one have this issue with lottie ?

How do you share arbitrary file resources among native projects?

$
0
0

The documentation on localization suggests using .Resx files. These work great if added to the .iOS or .Droid project directly, but completely fail to work in the shared project. It also doesn't seem to be possible to reference files in the shared project from a RESX in the platform projects. When I add files, it always copies them into the resources dir, meaning we have to duplicate everything between projects.

The various bug reports and forum threads I've seen about this suggest using a PCL project. This would be fine, except the PCL only allows strings inside RESX files. You can't bundle images or other arbitrary files.

Xamarin has stated that they have no intention of fixing this issue with shared projects, but PCL simply isn't sufficient.

Has anyone else found a way to embed resources in both iOS and Android projects without duplicating them in the repository? I've also tried symbolic links with "add existing item" but it still tries to copy the files themselves.

What does this mean?? I get this each time I build after coming back to the project!

$
0
0

This makes no sense to me... I get this error each time I come back to this bloody project... it tell me when I go build the android project in xamarin forms...
Af first it seem like the solution was to switch the selectors at the top of visual studio debug to x86 my android project and click the green error and the android project would in the android emulator...

Now it will not do that and I don't know why... can any one lend any insight on this...
Thanks!

Error ADB0020: The package does not support the CPU architecture of this device.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\21\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:

line 337 at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task`1 t) in E:\A_work\21\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:

line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() at System.Threading.Tasks.Task.Execute()0 Build

This is the warning which may be more helpful

Warning There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "My App Location", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. MyApp.Android

**UPDATE Looks like you have to have the option shared runtime clicked on for it to wrok in the emulator I guess... Its very odd all the hoops you have to jump through...

trouble with xamarin android compilation

$
0
0

A cursory search for this on google did not return any results, so feel free to point me towards anyone else having the same issue.

So I am trying to export an object through the javascript interface to a webview component. One of my objects works fine, another fails to compile.

The one that fails is defined as such:

public class ModelRepoWrapper : Java.Lang.Object {

            private ModelRepository repo;

            public ModelRepoWrapper(ModelRepository repo) {

                this.repo = repo;

            }

            [Export("set")]
            [JavascriptInterface]
            public void set(string name, BaseModel model) {
                repo.set(name, model);
            }

            [Export("get")]
            [JavascriptInterface]
            public object get(string name) {
                return (object)repo.get<BaseModel>(name);
            }
        }

On build, the compiler is throwing the following error:

Error 47 Failed to create JavaTypeInfo for class: myandroid.ModelRepoWrapper due to System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Android.Tasks.JavaTypeInfo.Signature..ctor(String name, String signature, String connector, String managedParameters, String outerType, String superCall)
at Xamarin.Android.Tasks.JavaTypeInfo.Signature..ctor(MethodDefinition method, ExportAttribute export)
at Xamarin.Android.Tasks.JavaTypeInfo.AddMethod(MethodDefinition registeredMethod, MethodDefinition implementedMethod)
at Xamarin.Android.Tasks.JavaTypeInfo..ctor(TypeDefinition type, String outerType, Object log)
at Xamarin.Android.Tasks.JavaTypeInfo..ctor(TypeDefinition type, Object log)
at Xamarin.Android.Tasks.Generator.GenerateJavaSource(TaskLoggingHelper log, TypeDefinition t, String outputPath, Boolean useSharedRuntime, Boolean hasExportReference)

Obviously I am doing something wrong, but I'm not really clear on what.. Any thoughts?


Trouble with xamarin android compilation

$
0
0

public class WebviewRendererEX : WebViewRenderer
{

    Context _context;

    public WebviewRendererEX(Context context) : base(context)
    {
        _context = context;
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
    {
        base.OnElementChanged(e);

        if (Control != null)
        {
            CookieManager cm = CookieManager.Instance;
            cm.SetAcceptCookie(true);
            cm.SetAcceptThirdPartyCookies(Control, true);
            Control.Settings.JavaScriptEnabled = true;
            Control.Settings.DomStorageEnabled = true;
            Control.AddJavascriptInterface(this, "Android");
            Device.BeginInvokeOnMainThread(() =>
            {
                Control.EvaluateJavascript("function someNavigate(dict){Android.navigateTo(dict);}", null);
            });    
        }
    }
}

public class WebViewJavaScriptInterface : Java.Lang.Object
{

    private Context context;

    /*
     * Need a reference to the context in order to sent a post message
     */
    public WebViewJavaScriptInterface(Context context)
    {
        this.context = context;
    }

    /* 
     * This method can be called from Android. @JavascriptInterface 
     * required after SDK version 17. 
     */

    [Java.Interop.Export("navigateTo")]
    [JavascriptInterface]
    public void NavigateTo(Dictionary<string, object> dict)
    {

        Console.WriteLine(dict);

    }

}

I have written the above code in webivew

On build, the compiler is throwing the following error:

Error Failed to create JavaTypeInfo for class: App.Droid.Controls.WebViewJavaScriptInterface due to System.NullReferenceException: Object reference not set to an instance of an object.
at Java.Interop.Tools.JavaCallableWrappers.JavaCallableWrapperGenerator.Signature..ctor(String name, String signature, String connector, String managedParameters, String outerType, String superCall)
at Java.Interop.Tools.JavaCallableWrappers.JavaCallableWrapperGenerator.Signature..ctor(MethodDefinition method, ExportAttribute export)
at Java.Interop.Tools.JavaCallableWrappers.JavaCallableWrapperGenerator.AddMethod(MethodDefinition registeredMethod, MethodDefinition implementedMethod)
at Java.Interop.Tools.JavaCallableWrappers.JavaCallableWrapperGenerator..ctor(TypeDefinition type, String outerType, Action2 log) at Java.Interop.Tools.JavaCallableWrappers.JavaCallableWrapperGenerator..ctor(TypeDefinition type, Action2 log)
at Xamarin.Android.Tasks.Generator.GenerateJavaSource(TaskLoggingHelper log, TypeDefinition t, String outputPath, String applicationJavaClass, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference) MGM.Droid

Obviously I am doing something wrong, but I'm not really clear on what.. Any thoughts?

Thanks In Advance.

Forms or Android ?

$
0
0

I want to building apps "fastly". IOS not importand for me.
Which one i must use? xamarin.android or xamarin.forms ?

Which one is easyer?

How create this UI? (Sample Picture inside)

$
0
0

Hi everyone,

I want this wavy layout, but don't known how to do it

I wish everyone a good day :)

Unable to scan Driving Licence(Barcode PDF417) using Zxing

$
0
0

I am using following code for DL scan. DL scan is not working.

 var options = new MobileBarcodeScanningOptions
          {
            AutoRotate = false,
            UseFrontCameraIfAvailable = false,
            TryHarder = true,
             CameraResolutionSelector = HandleCameraResolutionSelectorDelegate,
              PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.PDF_417 }
           };

   var QRScanner = new ZXingScannerPage(options);

   await Application.Current.MainPage.Navigation.PushAsync(QRScanner);

   CameraResolution HandleCameraResolutionSelectorDelegate(List<CameraResolution> availableResolutions)
     {
                        //Don't know if this will ever be null or empty
                        if (availableResolutions == null || availableResolutions.Count < 1)
                            return new CameraResolution() { Width = 800, Height = 600 };

                        return FindHighestResolution(availableResolutions);
    }

   private CameraResolution FindHighestResolution(List<CameraResolution> availableResolutions)
    {
            CameraResolution max = availableResolutions[0];
             foreach(CameraResolution cameraResolution in availableResolutions)
                {
                            if (max.Width < cameraResolution.Width)
                            {
                                max = cameraResolution;
                            }
                }
               return max;
     }

please help. Thanks in advance.

How to resolve sequence contains no elements while using tag

$
0
0

Here I need to put an image at the top of the page but I can't and I got a message like "Sequence contains no elements". I already referred about this but, I can't find any better solution. Help me if u aware of this.. Thanks in advance :smile:

Here is my code sample,

<ContentPage.Content>
    <Image HeightRequest="40" HorizontalOptions="End"
   Source="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRSyKVTjLq0GPFdi7h9if0qeTa4K1uDvA72FO6eoVLJJ__rNuXRtw"/>
    <StackLayout>
                   <!------rest of my code ---------->
    </StackLayout>
</ContentPage.Content>
Viewing all 204402 articles
Browse latest View live