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

Does that InputTransparent="True" eve work?

$
0
0

In the past there were so many bugs regarding InputTransparent="True" and today seems to be still not working. I am trying InputTransparent=True on my page which Rg.popup page so, it should transfer the touch to the backround but, it doesnt work. Is there a know bug for that?




Display Switch coltrol between Xamarin form 3.5 and Xamarin form 4.6

$
0
0

I migration xamarin project from XF 3.x with to 4.6 with ios 11,12 and The currently displayed Switch control differs between the two versions, Can anybody tell me why? Thanks
XF 3.5

XF 4.6

How to create the given menu by giving input a dynamic list

Xamarin form android scrolling lag ,,,

$
0
0

Hello everyone I have this layout and i am displaying the images from image i have on the android and the ios on ios scrolling works very smoth but android the is some lag while scrolling

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
             xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"
             mc:Ignorable="d"
           BackgroundImageSource = "backgroundmenu.png"
             FlowDirection="LeftToRight"
             x:Class="ooo.Views.MainPage1">
    <ContentPage.Content>

        <!--BackgroundImageSource = "backgroundmenu.png"-->
        <StackLayout>
            <Grid >

                <Grid.RowDefinitions>
                    <RowDefinition Height="80"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition   Width="50" />
                    <ColumnDefinition   Width="*" />
                    <ColumnDefinition   Width="50" />
                </Grid.ColumnDefinitions>

                <ImageButton  Grid.Row="0" Grid.Column="2"  BackgroundColor="Transparent" HorizontalOptions="End" WidthRequest="20" Margin="0,0,15,0" Source="sidemenu.png" x:Name="sidemenuoo" Clicked="sidemenuoo_Clicked" />
                <Image   Grid.Column="1" Grid.Row="0" Source="ooo.png" WidthRequest="100" VerticalOptions="Center" />

            </Grid>
            <flv:FlowListView  SeparatorVisibility="None"  x:Name="MainFrontPageList" HasUnevenRows="True" FlowColumnCount="2" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"   IsPullToRefreshEnabled="False">

                <flv:FlowListView.FlowColumnTemplate>
                    <DataTemplate>
                        <ffimageloading:CachedImage 
                            Margin="0,0,0,0" 
                              WidthRequest="200"
                                    HeightRequest="200"
                                      FadeAnimationEnabled="False"
                                         Source="{Binding UrlImage}" 
                                         CacheType="All"
                             VerticalOptions="Fill"
                                    HorizontalOptions="Center"
                                 >
                            <ffimageloading:CachedImage.GestureRecognizers>
                                <TapGestureRecognizer  Tapped="mashweer_Clicked_1"  CommandParameter="{Binding ClikeLink}" />
                            </ffimageloading:CachedImage.GestureRecognizers>
                        </ffimageloading:CachedImage>
                    </DataTemplate>

                </flv:FlowListView.FlowColumnTemplate>
            </flv:FlowListView>
        </StackLayout>

    </ContentPage.Content>
</ContentPage>

Xamarin TabbedPage Issue

$
0
0

Hello everyone!
am having a major issue with xamarin tabbed page
There is one tabbed page in my xamarin project called TodayTabbedPage so by default in android, Tabs will be shown at the top side so I write following code in tabbed page XAML file to place them at bottom
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
android:TabbedPage.ToolbarPlacement="Bottom"
android:TabbedPage.BarItemColor="#262626"
android:TabbedPage.BarSelectedItemColor="#9900CC"
So It perfectly showing all tabs at the bottom
But whenever am calling another tabbed page instead of TodayTabbedPage the bottom tab line still shows
Hope this information is enough please help!!!

Upload png or jpg to a server

$
0
0

Hello everyone. I hope you guys are doing OK

I have a problem: I need to update the profile picture of the user.

I am using @JamesMontemagno plugin, to take the picture or take the picture


Everything work fine an dandy

I need to update the actual file png or jpg to the API i am using (my server does not support bytes)

I tried a couple of things:

1)

var img = new Image {
                Source = Path.GetFileName(mediaFile.Path)
            };

Witch produce this error: Self referencing loop detected for property 'ParentView' with type 'Xamarin.Forms.Image'. Path 'avatar.Source'.'

2) I tried to use the File updater plugin, witch internally use a POST (https://github.com/CrossGeeks/FileUploaderPlugin/tree/master/src) and my api dont support post

3) I tried to sent get the filename, using

var image = Path.GetFileName(mediafile.path) \\ but image is of type string

this is my code to send to server:

public static async Task<HttpResponseMessage> UploadFileAsync(string token, Dictionary<string, Image> avatarImg) {

            var jsonString = JsonConvert.SerializeObject(avatarImg);
            var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");

            Debug.WriteLine("http" + httpContent.ToString());

            using (HttpClient client = new HttpClient()) {

                var serverAdress = Constants.AVATAR;
                client.DefaultRequestHeaders.Add("Authorization", "jwt " + token);

                var response = await client.PutAsync(serverAdress, httpContent);

                return response;
            }

the reason I am Jsonising my diccionary, is becouse my format is

{ avatar: picture_goes_here }
4) I tried sending bytes, but the server dosent undertand bytes (and the server is not mine)

I researched a little bit and they recommend using WebClient, but I want to use http client (is newer and faster)

That for the help in advance

Hide navigation bar for splash screen

$
0
0

Hi, I'm setting a splash screen and I would want to remove the navigation bar. I'm able to do it using

[Activity(Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true, ScreenOrientation = ScreenOrientation.Landscape)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
Window.DecorView.SystemUiVisibility = (StatusBarVisibility) SystemUiFlags.HideNavigation;
base.OnCreate(bundle);
Window.AddFlags(WindowManagerFlags.Fullscreen);
StartActivity(typeof(MainActivity));
}
}

but the problem is that it only happens after a few seconds, and before that the background image is stretched. So what it happens

  1. The splash screen loads, the image appears stretched.
  2. Initial activity enters OnCreate, the flag is set and the navigation bar dissapears. Image shows ok, but just for a moment.
  3. Main activity starts.

Is there a way to set the flag from the very beginning? I cant use 9patch technics because the image I'm asked to use has borders.

clear data of applications installed

$
0
0

Ho can i delete all data(clear data) of all applications installed in my android device?
link bellow :
http://stackoverflow.com/questions/19830706/kill-another-application-and-clear-its-data
converted to C# android xamarin!

` public static void DeleteAllApps(Context _context)
{
Intent mainIntent = new Intent(Intent.ActionMain, null);
mainIntent.AddCategory(Intent.CategoryLauncher);
IList<Android.Content.PM.ResolveInfo> pkgAppsList = _context.PackageManager.QueryIntentActivities(mainIntent, 0);
for (int i = 0; i < pkgAppsList.Count; i++)
{
try
{
ActivityManager activityManager = (ActivityManager)_context.GetSystemService(Context.ActivityService);
activityManager.KillBackgroundProcesses(pkgAppsList[i].ResolvePackageName);
clearApplicationData(pkgAppsList[i].ResolvePackageName, _context);

            }
            catch(Exception ex)
            {
            }
        }

    }
    static void clearApplicationData(String packageName, Context _context)
    {
        File cache = _context.CacheDir;
        File appDir1 = new File(cache.Parent).ParentFile;
        File appDir = new File(appDir1.AbsolutePath + "/" + packageName);
        if (appDir.Exists())
        {
            String[] children = appDir.List();
            foreach (string s in children)
            {
                if (!s.Equals("lib"))
                {
                    deleteDir(new File(appDir, s));
                }
            }

        }
    }
    static bool deleteDir(File dir)
    {
        if (dir != null && dir.IsDirectory)
        {
            String[] children = dir.List();
            for (int i = 0; i < children.Length; i++)
            {
                bool success = deleteDir(new File(dir, children[i]));
                if (!success)
                {
                    return false;
                }
            }
        }
        return dir.Delete();
    }`

Carouselview not showing in iOS (Xamarin.Forms - 3.6.0.709228)

$
0
0

I am using xamarin.forms 3.6.0.709228. and I am trying to implement CarousleView which works fine in android but not showing in iOS. Is there any bug with Xamarin.Forms(3.6.0.709228) version ? or Is there any workaround to use CarouselView with Xamarin.Forms(3.6.0.709228) ?

tabs of tabbed pages have disappeared

automatically refresh listview when adding an item

$
0
0

I have a listview and a button inside a fragment. When I click the button a dialog is shown to prompt the user to enter the data to be store. When dialog is accepted the listview should refresh and show the new item. How I can make this possible ?

Browsing SQL Lite database on Android Emulator

$
0
0

I am currently trying to find a way to browse the SQL Lite database that my app creates on an android emulator. All the postings out there indicate that while my app is running on the emulator, in visual studio I need to open Android Device Mointor, and under file explorer do a pull from the data\data folder onto my local system (windows 10). I can then browse the files, including the database of my app.

However unlike all the postings, my data folder is either empty or simply does not have the .db file that I am expecting to find.

I have tried this method on the following emulators.

  • Pixel 2 Pie 9.0 API 28
  • Oreo 8.0 API 26
  • Marshmello 6.0 API 23
  • Lolipop 5.0 API 21

The latest versions (pixel / oreo) dont even allow you to browse the data folder (expanding it in file explorer comes up empty). The older versions have data in their data folders but not no .db files affilicated with my app. Just a bunch of .so files.

My Development Environment

  • Visual Studio 2019
  • Windows 10

Would really appreciate input here as its all but impossoible to develop seriously without access to the database on an android device.

Simple way to poll server from Xamarin.Forms client

$
0
0

Hi there
I have to implement a polling code to send a device App status to a server (I use WCF) and get a command from the server to be executed (if at all).
It polls each, say, 10 seconds regardless whether the app commands the screen or the device is hibernating (I mean it screen gets black while it left untouched for a time).
Can I just attach my PollingTimerClass to the Application.Current and start it in OnStart() event handler?
Again, it must poll when:
1. Application is active
2. Application is not active. It is pushed by another application on the screen
3. Device is a black screen, but it is not off

Thanks.

Xamarin Google(GoogleApiClient) SignOut

$
0
0

Hi
hear i am facing a problem to get signout feom the GoogleApiClient, the following is the code i am using currently,

Here is for the Signin

 protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                //Common.packageName = ApplicationContext.PackageName;
                SetContentView(Resource.Layout.activity_gmail);
                Common.clearCatchecontext = this;//ApplicationContext;

                FindViewById(Resource.Id.sign_in_button).Click += GoogleSignInButton_Click;   

                var gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn)
                        .RequestIdToken("5423.apps.googleusercontent.com")
                        .RequestEmail()
                        .Build();

                Common.mGoogleApiClient = new GoogleApiClient.Builder(this)
                        .EnableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                        .AddApi(Android.Gms.Auth.Api.Auth.GOOGLE_SIGN_IN_API, gso)
                        .Build();
                Common.mGoogleApiClient.Connect();
                Common.mAuth = FirebaseAuth.Instance;

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace + ex.InnerException);
            }
        }

once after success signin the application will call the LoadApplication(App) to redirect from pureAndroid Platoform to the crossPlatoform,
then to signOut, form the xamarin forms will call the android method as dependency injection,

Interface class and a method,

 public interface ISignOut
    {
       void SignOuts(string _value);
    }

the below is the button click,

  private async void TapRecognizserLogOut_Tapped(object sender, EventArgs e)
        {
            try
            {
                var result = await DisplayAlert("Alert!", "Do you really want to Logout the application?", "Yes", "No");
                if (result)
                {
                    if (Xamarin.Forms.Device.OS == TargetPlatform.Android)
                    {

                        DependencyService.Get<ISignOut>().SignOuts("HAI");

                    }
                }

            }
            catch (Exception ex)
            {

                System.Diagnostics.Debug.WriteLine(ex.InnerException + ex.StackTrace + ex.Message);
            }
        }

in the android implementation is below,

[assembly: Xamarin.Forms.Dependency(typeof(GmailSignInActivity))]
namespace Xaamrin_Mobile.Droid
{
    [Activity(Label = "GmailSignInActivity", Theme = "@style/MainTheme")]
    class GmailSignInActivity : AppCompatActivity, GoogleApiClient.IOnConnectionFailedListener, GoogleApiClient.IConnectionCallbacks, ISignOut
    {

     public async void SignOuts(string _value)
        {
            try
            {
                if (true)
                {
                    var _res = LoginUser._loginUser;



                    FirebaseAuth.Instance.SignOut();
                    if (!Common.mGoogleApiClient.IsConnected)
                    {
                        Common.mGoogleApiClient.Connect();
                        await Auth.GoogleSignInApi.SignOut(Common.mGoogleApiClient);//.GetAwaiter().GetResult();

                    }

                    Common.mGoogleApiClient.Disconnect();
                    Common.mGoogleApiClient.Connect();
                    var user = FirebaseAuth.Instance.CurrentUser;

                }
                           }
            catch (Exception ex)
            {
                //throw;
            }
            var intent = new Intent(Forms.Context, typeof(GmailSignInActivity));
            Forms.Context.StartActivity(intent);
            //return false;

        }
    }

}

like the above way, we are implemented, but we are not able to get signout from the GoogleAPIClient,

Xamarin iOS Azure Notification Hubs with Xcode 11.3 and iOS 13.3 Issue

$
0
0

Hey we're hitting this issue on all devices with iOS v13.3.1 with Xamarin IOS. It seems to be related to a change in the format for the device token:

iOS 13.3:
{length = 32, bytes = 0xf1d219ab c4aab6f4 e0408ae2 8a6e9a5c ... c6ddccbb 6a63fe2f }

iOS 12:

We are unsure if there is an underlying issue with the SDK, or out of our own fault, but we are using Xamarin.Azure.NotificationHubs.IOS v2.0.4. Registration happens client side on the device.

Originally we had this:

        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            _notificationDelegate.Register(_user.UserId, deviceToken);
        }
public void Register(string userID, NSData deviceToken)
        {
            _hub = new SBNotificationHub(
               Configuration.Configuration.NOTIFICATION_HUB_CONNECTION_STRING,
               Configuration.Configuration.NOTIFICATION_HUB_NAME);

            _hub.UnregisterAll(deviceToken, (unregisterError) => {
                if (unregisterError != null)
                {
                    _handler.LogError($"UnregisterAll error: {unregisterError.ToString()}");
                    return;
                }

                _handler.LogInfo($"UnregisterAll complete for user: {userID}. Starting RegisterNative");

                var tags = new NSSet($"username:{userID}");
                _hub.RegisterNative(deviceToken, tags, (registerError) =>
                {
                    if (registerError != null)
                    {
                        _handler.LogError($"RegisterNative error: {registerError}");
                    }
                    else
                    {
                        _handler.LogInfo($"RegisterNative registered: {deviceToken} for user ID: {userID}");
                        IsRegistered = true;
                    }
                });
            });
        }

This does not work anymore. RegisterNative does not get called so the device never appears in the notification hub. Given the new formats and form posts I've read online, the new code is as follows:

 public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            byte[] token = deviceToken.ToArray();
            string registrationToken = BitConverter.ToString(token).Replace("-", "");

            _notificationDelegate.Register(_user.UserId, NSData.FromString(registrationToken));
        }

In this case, the device gets registered but is deleted immediately on using the TEST SEND feature in azure notification hubs, presumably because the registration is actually invalid with the conversion. Is this a valid way to register iOS 13.3 devices with Notification Hubs, or is something else up? Note: our iOS 13.1 devices running the app built against Xcode 10 do work, and so do our iOS 12 devices.


On Shell Custom renderer have problem?

$
0
0

On Shell Custom renderer have problem? when I build the project my flyout menu and my bottom navigation tabbar background color are not working ?

custom renderer for bottom navigation tab font size smaller and bigger icon fontsize ? thanks

Project Class

public class CShell: AppShell
{

}

Adroid Class

[assembly: ExportRenderer(typeof(AppShell), typeof(CShellRenderer))]
namespace Goo4.Droid.Renderers
{
public class CShellRenderer : ShellRenderer
{
    public CShellRenderer(Context context) : base(context)
    {
    }
    protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
    {
        return new CBottomNavViewAppearanceTracker();
    }

}


public class CBottomNavViewAppearanceTracker : IShellBottomNavViewAppearanceTracker
{
   public void Dispose()
    {

    }

    public void ResetAppearance(BottomNavigationView bottomView)
    {

    }

    public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
    {
            IMenu menu = bottomView.Menu;
        for (int i = 0; i < bottomView.Menu.Size(); i++)
        {
            IMenuItem menuItem = menu.GetItem(i);
            var title = menuItem.TitleFormatted;
            SpannableStringBuilder sb = new SpannableStringBuilder(title);

            int a = sb.Length();

            //here I set fontsize 20
            sb.SetSpan(new AbsoluteSizeSpan(11, true), 0, a, SpanTypes.ExclusiveExclusive);

            menuItem.SetTitle(sb);
        }
    }
   }
}

ios Class

[assembly: ExportRenderer(typeof(AppShell), typeof(CShellRenderer))]
namespace Goo4.iOS.Renderers
{
    public class CShellRenderer : ShellRenderer
    {
        public CShellRenderer() : base()
        { }

        protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
        {
            return new CTabbarAppearance();
        }
    }

    public class CTabbarAppearance : IShellTabBarAppearanceTracker
    {
        public void Dispose()
        {

        }

        public void ResetAppearance(UITabBarController controller)
        {

        }

        public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
        {

        }

        public void UpdateLayout(UITabBarController controller)
        {

        }
    }
}

iOS 13.0 Broke MasterDetailPage on iPads?

$
0
0

I have noticed that after updating iOS to v13.0, the MasterDetailPage is broken on iPads but it's still working on iPhones and Androids.
By broken I mean the whole page is white, without content.


The only way to fix this is to update Xamarin.Forms to the latest v4.2+.

The problem is that some other packages are not compatible (XF broke something else after v4.0) so I cannot update XF yet.
The App Store is rejecting my app because it shows a white screen on iPads with iOS 13.0+....so I would have to stop targeting iPads!

Try for yourself, here is a basic sample repo with MasterDetail page (the default Xamarin Forms template with MasterDetailPage).
https://github.com/stesvis/MasterDetailTest2

The same happens with Prism MasterDetailsPage:
https://github.com/stesvis/MasterDetailTest

  • iPhones: works
  • iPad -> iOS 12.2: works
  • iPad -> iOS 13.0: white screen

Any solution for this HUGE headache?

Why is the Cognitive Services Speech Library not being deployed?

$
0
0

When trying to build and deploy a Xamarin cross-platform iOS project using Azure Cognitive Services Speech in the PCL, I am encountering the following error message:

"C:\Projects\IdentityCheckpoint\VS2020\Sentry\Sentry\Sentry.iOS\Sentry.iOS.csproj" (Build;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) -> 2>(_CompileToNative target) -> 2> C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(884,3): error MT0009: Error while loading assemblies: /Users/xxx/Library/Caches/Xamarin/mtbs/builds/xxx.iOS/44d8d7434e850748f5ee25da92692acc/bin/iPhone/Debug/device-builds/iphone12.1-13.6/Microsoft.CognitiveServices.Speech.core.dll.

The problem isn't present for the other platforms. This a new issue using the latest VS Preview and Nuggets.

Face exception in some device when click in entry "Java.Lang.NullPointerException: 'activityToken'"

$
0
0

face exception in on focused entry in some device like Samsung j7.

"Java.Lang.NullPointerException: 'activityToken'"

Cannot get SerialPortInfo through Intent Xamarin Forms

$
0
0

Hello guys!

I am extremely new to Xamarin Forms.

I am trying to connect to Serial Port through Android OS & I am using Xamarin Forms.

I found a project on BitBucket which uses a specific dll to communicate with the Serial Port. I have attached the project for you reference. The dll can be found in the debug folder of the same.

The sample project works flawlessly. However, since it was just an activity and had no UI, I had to create my own project with buttons to open and close the connection with the Serial Port.

I copied all the code from the sample project and added it to my app. However, the following line causes an error due to which I am not able to compile :

portInfo = Intent.GetParcelableExtra(EXTRA_TAG) as UsbSerialPortInfo;

This is the error - "An object reference is required for the non static field method or property Intent".

How can I resolve this error?

Thank You! :)

Viewing all 204402 articles
Browse latest View live


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