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

Switch SF app with another app

$
0
0

Hi All,

I need to launch another 3rd party's app from my app and after performing certain operation need to switch back to my app again.
Soon after launching the other app there will be a call to a web service which will return the result related to the operation done with 3rd party app.
I could able to launch the 3rd party app but remaining part is to switching back to my app after web service return.
Is there a way I can get this done?

Thanks
Kaushalya


When Editor is focused it converts text into horizontal scroll

$
0
0

Hi Guys... I have an application which is using Editor. When I focus on editor, it converts my text to horizontal line like this. Can you guys guide me what to do? How to handle? Any kind of help is appreciated.

Regards!

Native lockscreen/drawer audio controls from WebView

$
0
0

Hi community.

Currently i have a website which sole purpose is to play audio from an audio-player. I'm working on loading this Audio-player into a webview in Xamarin.Forms; all working just fine and playing the audio.

Now, if i lock the screen or minimize the app, the audio continues playing, but native controls in the notification-drawer or lockscreen( To pause, resume etc.) is not visible; i would like to have these though.

I'm struggling to find any info on this and hope that some of you may be of assistance.

Is it possible to toggle this in a simple way (As it happens automatically with etc. browsers) Or do i have to make a Hybrid WebView and implement them myself, based on javascript events?

looking forward to hearing from you, thanks in advance.

// J

Is there a way to hyperlink within a page in a Xamarin Forms view?

$
0
0

I am hoping to put a link at the top of my view that, when clicked, will cause the view window to scroll down to show another element on the page at the top of the page. I've tried setting the name of the destination element and referencing it in an anchor element with the name preceded by '#', as I would on the web

e.g. Click here to scroll

Lots of intermediary content...
My element to scroll to

Clicking the link 1) calls the server's LoadFinished method in the ContentPage and 2) does NOT scroll the view to the selected element. How is linking to a location in the view accomplished in Xamarin.Forms?

BindingContext: use the same resource for a datatemplate and a contentview

$
0
0

I've got a challenge with binding context. I've got a listview that has a template selector. The template selector uses different data templates based on the data that is being displayed. The bindingcontext looks something like <label Text="{Binding Name}"/>. This works well. I would now like to use the same data template in a contextview to populate the ControlTemplate. The layout renders correctly. The bindingcontext looks something like <label Text="{TemplateBinding BindingContext.Name}"/>. This also works. However, I have to change the way the bindingcontext is specified. Is there away to use the same data template between both the listview and the contentview without changing the bindingcontext? I'm trying to avoid having the same layout twice to support different bindingcontext styles.

Thanks!

How to create xls file (Excel)

$
0
0

Hi guys,
how can I create xls file? Do you know any free methods?

XF 4.7 UWP tabbedpage toolbaritem Icon is too small

$
0
0

In my uwp app using png icon, it displays really tiny. Actual png is 64x64

but this is displayed like 16x16. I use the simple code below. I see there is FontSource with size support. is there any hack possible for png or svg if possible?

 var toolBarItem = new ToolbarItem
                    {                            
                        Order = ToolbarItemOrder.Primary, 
                        icon = "download.png",                  
                    };

Android: Unable to resolve host ”covid19.mathdro.id“: No address associated with host

$
0
0

Hi,

I'm using the Xamarin form for building the App and using httpclient (modernhttpclient-updated nuget) for getting the API data from https://covid19.mathdro.id. When test the app ios is working but android throw an exception " Unable to resolve host ”covid19.mathdro.id“: No address associated with host". last time the android has no problem don't know maybe update mono or SDK can cause of this problem?

I'm also try changed back modernhttpclient to AndroidClientHandler, the issue same as above "unable to resolved host ....."

I was used "HTTPS" for accessing this api end point, https://covid19.mathdro.id/api/countries/ID (using postman and browser can be viewed)

Here is my current info: NUGET, Compile version target framework, Android Manifest, Android Build, VS 2019 updated, SDK updated, open jdk updated info, nslookup for checking "covid19.mathdro.id":

=================================
NUGET Xamarin Android and iOS (Shared Project):
Xamarin Forms 4.7.0.968
Xamarin Essential 1.5.3.2

NUGET for core app (.NET standard project):
Framework: .NET Standard Library 2.1.0
modernhttpclient-updated 3.4.3
polly 7.2.1
Newtonsoft.Json 12.0.3

=================================
Compile Android Version (Target Framework): Android 10.0 (Q)

=================================

Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.corona.news.kmedia">
  <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="30" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.CALL_PHONE" />
  <uses-permission android:name="android.permission.GET_TASKS" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  <uses-permission android:name="android.permission.USE_BIOMETRIC" />
  <uses-permission android:name="android.permission.USE_FINGERPRINT" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
  <application android:label="CoronaNews.Droid"> 
                 
    </application>
</manifest>

================================
Android Build:

HttpClient Implementation: AndroidClientHandler (I tried another option: default and managed, no luck)
SSL/TLS Implementation: Native TLS 1.2+

=== Visual Studio Community 2019 for Mac ===

Version 8.6.5 (build 23)
Installation UUID: 2774e73f-ab00-4072-8e8a-240175d71130
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 610000104

=== Mono Framework MDK ===

Runtime:
Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
Package version: 610000104

=== Roslyn (Language Service) ===

3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

=== NuGet ===

Version: 5.6.0.6591

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.301/Sdks
SDK Versions:
3.1.301
3.1.300
3.1.200
3.1.102
3.1.101
3.1.100
3.0.101
3.0.100
2.1.701
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.5
3.1.4
3.1.2
3.1.1
3.1.0
3.0.1
3.0.0
2.1.19
2.1.18
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12

=== Xamarin.Profiler ===

Version: 1.6.12.26
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.5 (16139)
Build 11E608c

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

=== Xamarin Designer ===

Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

=== Xamarin.Android ===

Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/kok.sang/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.3
SDK Build Tools Version: 30.0.0

Build Information:
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/kok.sang/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:42:50 UTC

=== Android Device Manager ===

Version: 16.6.0.96
Hash: 6e8b80b
Branch: remotes/origin/d16-6
Build date: 2020-06-10 22:43:28 UTC

=== Build Information ===

Release ID: 806050023
Git revision: 5289d413b99fddfc20b4ecf3e445ccb822213427
Build date: 2020-06-18 12:08:30-04
Build branch: release-8.6
Xamarin extensions: 5289d413b99fddfc20b4ecf3e445ccb822213427

=== Operating System ===

Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
Tue May 26 20:41:44 PDT 2020
root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Android Signature Tool 2.2.0


Java SDK

microsoft_dist_openjdk_8.0.25

java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)


nslookup covid19.mathdro.id

Server: 192.168.8.1
Address: 192.168.8.1#53

Non-authoritative answer:
covid19.mathdro.id canonical name = alias.zeit.co.
Name: alias.zeit.co
Address: 76.76.21.21


Geofence

$
0
0

Hello, I need to implement a geo-fence service for iOS and Android, which works in the background, as I need to send the information to the back-end as soon as the person leaves a certain fence, any implementation tips?

How to change Navigation back button icon

$
0
0

Hi all i tried a lot to change back button icon on both Android & IOS but the problem is that when i push async to another page and return back i got the default back button not the one i created, i'm using a toolbar

here is my code:

public class SpaceNavigationPageRenderer : NavigationPageRenderer
    {
        private Android.Support.V7.Widget.Toolbar toolbar;
        public Activity context;

        public override void OnViewAdded(Android.Views.View child)
        {
            base.OnViewAdded(child);
            if (child.GetType() == typeof(Android.Support.V7.Widget.Toolbar))
            {
                toolbar = (Android.Support.V7.Widget.Toolbar)child;
                toolbar.ChildViewAdded += Toolbar_ChildViewAdded;
               // toolbar.NavigationIcon = Android.Support.V4.Content.ContextCompat.GetDrawable(context, Resource.Drawable.AppIcon);

                toolbar.SetNavigationIcon(Resource.Drawable.AppIcon);
            }
        }

        protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
        {
            base.OnElementChanged(e);
            context = (Activity)Xamarin.Forms.Forms.Context;
            //toolbar = context.FindViewById<Android.Support.V7.Widget.Toolbar>(Droid.Resource.Id.toolbar);

            toolbar.SetNavigationIcon(Resource.Drawable.AppIcon);

        }

        protected override Task<bool> OnPushAsync(Page view, bool animated)
        {
            var retVal = base.OnPushAsync(view, animated);

            context = (Activity)Xamarin.Forms.Forms.Context;
            //toolbar = context.FindViewById<Android.Support.V7.Widget.Toolbar>(Droid.Resource.Id.toolbar);

            if (toolbar != null)
            {
                if (toolbar.NavigationIcon != null)
                {
                    toolbar.NavigationIcon = Android.Support.V4.Content.ContextCompat.GetDrawable(context, Resource.Drawable.AppIcon);
                    //toolbar.SetNavigationIcon(Resource.Drawable.Back);
                }
            }
            return retVal;
        }

        protected override Task<bool> OnPopViewAsync(Page page, bool animated)
        {
            context = (Activity)Xamarin.Forms.Forms.Context;
            //toolbar = context.FindViewById<Android.Support.V7.Widget.Toolbar>(Droid.Resource.Id.toolbar);

            if (toolbar != null)
            {
                if (toolbar.NavigationIcon != null)
                {
                    //toolbar.NavigationIcon = Android.Support.V4.Content.ContextCompat.GetDrawable(context, Resource.Drawable.AppIcon);
                    toolbar.SetNavigationIcon(Resource.Drawable.AppIcon);
                }
            }
            return base.OnPopViewAsync(page, animated);
        }

Need to login with WebView then navigate to Forms pages [for both ios and android]

$
0
0

I'm working on a project which we need to authenticate users from a WebView page then navigation will be available for user pages. User pages are content pages. We need to write the token that returns from successful login to the device so navigation to the user specific pages will be available by comparing the login_key inside the Token with the DB version. Has anyone worked on something like this? and is this possible?

How to set Height of a Grid to "Auto" not the static value ?

$
0
0

Main Query => I have created a listview of certain data and there the data is coming from backend code( Accessing some API ).And presents the
elements of listview with some lebel in MainPage.xaml in a grid format. The Height of Grid is not adjusting with whole Grid
content automatically.
I set HeightRequest = 50, But as a result some data is pushed under the bottom line of the Grid.
I want the height of the grid to adjust the space needed to display different size of the grid value and to compact it,will be No pushed
under data.
** Simplification => How to set the grid height to Auto ?**

Xamarin Forms not Displaying new page when using with SDK

$
0
0

Hi all!

The project is done in Xamarin Forms but this is an iOS-specific problem because we do not use SDK on the Android project.

When trying to navigate from page to page neither on Simulator nor on real iPhone will Navigation.PushAsync(new TicketPage()); push to a new page while there is an on the TicketPage (this is the 'next' page, but it does not work no matter what page it is if it has in it).

There is no Error when trying to PushAsync to the next page.
When a field is removed from .xaml file it works as intended but since I need a multiline input field this is becoming an issue.

There is an AppConnectSDKBinding (SDK for Integration with MobileIron service) and when SDK is present the application does not show pages with in them.

Is there another Multi-line text input similar to that I can use because I have to have SDK in this project.

Badge count in Xamarin IOS when app is killed

$
0
0

I am trying to set the Badge count in Xamarin Forms application for IOS. I am using Azure notification Hub. Everything is working fine except the badge is not getting set when app is killed. I am sending the badge value from backend service.

Please let me know what i need to do to make it work even when the app is killed. I received the notification even the app is killed but badge count is not changing.

Here is my code

PushNotificationService.cs
public class PushNotificationService: IPushNotificationService
{
public DeviceInstallation GetDeviceRegistration(params string[] tags)
{
if (AppDelegate.DeviceToken == null)
{
return null;
}

        var registrationId= AppDelegate.DeviceToken;

        var installation = new DeviceInstallation
        {
            InstallationId = UIDevice.CurrentDevice.IdentifierForVendor.ToString(),
            Platform = "apns",
            PushChannel = registrationId
        };
        System.Diagnostics.Debug.WriteLine($"[service]: {installation.InstallationId}");
        // Set up tags to request
        installation.Tags.AddRange(tags);
        // Set up templates to request
       PushTemplate genericTemplate = new PushTemplate
        {

            Body = "{\"aps\":{\"alert\":{\"title\":\"$(messageTitleParam)\",\"body\":\"$(messageBodyParam)\"},\"content-available\":1,\"badge\" : \"$(badge)\",\"sound\":\"$(messageSound)\"},\"custom\":{\"orderid\":\"$(orderid)\",\"page\":\"$(page)\",\"dataBaseId\":\"$(notificationId)\"}}"
        };
        installation.Templates.Add("genericTemplate", genericTemplate); 
        return installation;
    }

    public string GetDeviceId()
    {

        return UIDevice.CurrentDevice.IdentifierForVendor.ToString();
    }


}

AppDelegate.cs

public override void DidReceiveRemoteNotification(
UIApplication application,
NSDictionary userInfo,
Action completionHandler)
{
NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;

        var badgecount= new NSString("badge");
        if (aps.ContainsKey(badgecount))
        {
           string count = (aps[badgecount] as NSString).ToString();
            BadgeImplementation badge = new BadgeImplementation();
            badge.SetBadge(Convert.ToInt16(count));
        } 

}

How to get back to app after google login

$
0
0

Hi Everyone,

I'm trying to implement google login in my app using xamarin.auth like below

var auth = new OAuth2Authenticator("284202576320-7kgdhaa5sgvkoe03jmmcv0p8lfdma306.apps.googleusercontent.com","cAZW7uegD-h2-
                                                             tNMMf5q1UGQ","https://www.googleapis.com/auth/userinfo.email",new 
                                                             Uri("https://accounts.google.com/o/oauth2/auth"),new 
                                                             Uri("http://dev.myfav.restaurant/Account/LoginComplete"),new 
                                                             Uri("https://accounts.google.com/o/oauth2/token"),null,true)
        {
            AllowCancel = true,                
        };

but Completed event not firing and its going to web page after login :( i need to get back user to my app how can i achieve this ???? Can anyone help me on this please.

Thanks in advance


Entry with numeric keyboard - no comma displayed on device

$
0
0

Hello,
I created a simple Entry with numeric keyboard like this:

<StackLayout x:Name="root" VerticalOptions="FillAndExpand" Spacing="0">
    <Entry Keyboard="Numeric"/>
</StackLayout>

On my Samsung device, I don't know why it is not displaying a button for a comma. In my country (Poland) the comma is used as a decimal separator so I want to be able to type it.

Anyone has encountered such a problem?

I will be grateful for any help.

CollectionView doesn't scroll when inside a Stacklayout inside a Grid inside another CollectionView

$
0
0

I'm not very surprised that this doesn't work. But perhaps I am missing something. As you can see, the last record is cut off by the edge of the Post and pulling it around only scrolls the parent CollectionView, not the CollectionView inside the Grid.

Page:

<ContentPage.Content>
<RefreshView>
<StackLayout>
<CollectionView ItemsSource="{Binding Posts}"> 
<CollectionView.ItemTemplate>
<DataTemplate><social:PostView /></DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</RefreshView>
</ContentPage.Content>

Post:

<ContentView.Content>
        <Frame>
            <StackLayout>
                <Grid>
                    <StackLayout>
                        <CollectionView ItemsSource="{Binding Suppliers}"> 
                            <CollectionView.ItemTemplate>
                                <DataTemplate>
                                    <datatemplates:SupplierSummaryTemplate /> 
                                </DataTemplate>
                            </CollectionView.ItemTemplate>
                        </CollectionView>
                    </StackLayout>
                </Grid>
            </StackLayout>
        </Frame>
    </ContentView.Content>

Xiaomi Badge Count

$
0
0

Hello, I've been trying to get my Xamarin Forms app to enable Badge Icon on notifications in my Xiaomi devices.

When I get a Firebase notification IF I HAVE ENABLED the badge icon notification I can see the notification number in the app icon in the Launcher.
To enable it I have to go to:


Once, that option is enabled I can see the number with the notification count in the launcher.
My question is how can I enable it by code?

For example, the Whatsapp app already had it enabled when I installed it, I didn't have to go enable it manually.
So there's a way of actually enabling it, but I can't find any documentation or anything.

I've dissasembled the Whatsapp app and the only thing I've found interesting was this class:

package X;

import android.app.Notification;
import android.content.Context;
import android.os.Build;
import com.whatsapp.util.Log;

/* renamed from: X.2MW  reason: invalid class name */
public final class AnonymousClass2MW extends C34431jX {
    public void A03(Context context, Notification notification, int i) {
        if (Build.VERSION.SDK_INT >= 19 && Build.MANUFACTURER.equalsIgnoreCase("Xiaomi")) {
            try {
                Object obj = notification.getClass().getDeclaredField("extraNotification").get(notification);
                obj.getClass().getDeclaredMethod("setMessageCount", new Class[]{Integer.TYPE}).invoke(obj, new Object[]{Integer.valueOf(i)});
            } catch (Exception unused) {
                Log.e("Could not set badge for Xiaomi notification");
            }
        }
    }
}

But I couldn't make it work in Xamarin. It doesn't give an error but it seems like that is only changing the number, not allowing/enabling the badge icon option.

Any help would be appreciated.
Thank You.

Images won't show in previewer, but will on phone.

$
0
0

I'm new to Xamarin development and since I started, I always have problems, now my images won't show in the previewer, but will on phone.
Images are in a drawable folder, set to AndroidResources (I'm developing for android).
If anyone can help I will appreciate that a lot, Thanks.

Is there a way to know when layout is over?

$
0
0

Hello,

I have implemented a custom renderer in Android that is managing and displaying a ViewPager.
Each page does a decent amount of work, and this can't really be changed.

Is there a lifecycle event, a listener I can attach to or some other way that guarantees that the component has been layed out and the measures are stable?
I retrieve the component's measures on OnSizeAllocated, but that gets called too many times.

Also using the ViewTreeObserver on Android is not a solution because for some reason it gets called too early when components bounds have not yet been determined.

Thanks

Viewing all 79144 articles
Browse latest View live


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