Is there any way to check app crash analytics for my xamarin forms(both android and ios)
Xamarin Forms appcrash analytics
TouchView | TouchImage | TouchFadeView | TouchColorView package
Hi all, let me introduce new plugin for Xamarin.Forms development.
https://github.com/AndreiMisiukevich/TouchEffect
This plugin allows developers to create UI-responsive controls/layouts with touch effect (fade control, change image source, change background color)
I will appreciate any feedback)
Oxyplot does not work undeer the listview grid
I have a listvew and when user taps the viewcell I open another grid under the listview with details related to the listview cell clicked(given the accordion control illusion).
But the oxyplot grphs dont work in iOS.They are fine in android.
The graphs appaear and vanish and sometimes appear in the next listview item grid instead of the listview item clicked.
My implementation is straight forward... Is this a bug?
Copy file from Resources to Library\Application Support
Hi there,
I have a SQLite database file that I have a default version of in my Resources directory that is set to copy to the output directory on build.
On app startup I check to see if the user already has my sqlite database file in place if not I want to copy the default file from the resource directory to the user's Library\Application Support directory which I understand is where my sandboxed application can store user data.
What I've not been able to work out programatically is where is my Resource directory path is so I can issue a copy command. I looked at NSHomeWindow() and sample code
[System.Runtime.InteropServices.DllImport("/System/Library/Frameworks/Foundation.framework/Foundation")]
public static extern IntPtr NSHomeDirectory();
public static string ContainerDirectory
{
get
{
return ((NSString)ObjCRuntime.Runtime.GetNSObject(NSHomeDirectory())).ToString();
}
}
And am assuming that I use ContainerDirectory as the string representation? However that doesn't seem to point to where my Resources folder is when the app is running.
Cannot keep ListView ordered/sorted when navigating away and back
Hello!
I'm learning the ListView control and sorting data it shows, but i can't seem to fix a scenario.
I am using Visual Studio 2017 Community.
I am trying to have a list always ordered by this criteria:
- column create date (DateTime.Now)
- order descending
The following 3 scenarios must work with the same order criteria applied, but i can't seem to make it work for the 3rd one.
1) (working) When i open the app the 1st time (done with sorting in overriden Init method
2) (working) When i add items in the list (enter/done/verify on a specific Entry control adds to my ListView an item)
3) (not working) When, while the app is running , i navigate to another Page and back to the one that keeps this ListView
1) was solved with overriding Init method of the viewModel (which keeps the ObservableCollection prop)
2) was solved by using ObservableCollection.Insert(,item) instead of ObservableCollection.Add()
3) In the view, i tried overriding OnAppearing
In XAML:
<ListView
x:Name="ItemListView"
ItemsSource="{Binding Items}"
CachingStrategy="RecycleElement"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout
Spacing="10"
Orientation="Horizontal"
>
<StackLayout>
<Label
Text="{Binding Code}"
/>
<Label
Text="{Binding Description}"
/>
</StackLayout>
<Label
Text="{Binding Number}"
FontAttributes="Bold"
VerticalOptions="Center"
/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
In code-behind of View:
protected override async void OnAppearing()
{
base.OnAppearing();
await _itemViewModel.SaveItem(); //does some SQLite work related to Items
_itemPageViewModel.SortItems();
ItemListView.ItemsSource = _itemViewModel.Items;
}
In View-Model:
internal void SortItems()
{
Items.OrderByDescending(x => x.CreateDate);
}
However, when i repeatedly exit the Page and reenter, the items are unsorted.
Introducing Xamarin.Essentials: Core Cross-Platform Native APIs for All Apps
Xamarin.Essentials APIs provide access to over 30 native features from a single cross-platform API library, which can be accessed from shared code no matter how the user interface is created. This means you can use Xamarin.Essentials APIs with a single Xamarin.Android app or a Xamarin.Forms app targeting iOS, Android, and UWP. Even though it’s packed with features, it’s still fully optimized for performance and minimal impact on app size, because the library takes full advantage of being linker safe. This means only the APIs and features you use will be included in your app and the rest will be removed when you compile your app.
Xamarin.Essentials gives you instant access to APIs from your shared code such as Sensors, Connectivity, App/Device Info, Preferences, Secure Storage (Keychain), Open Browser, Text-to-Speech, Geolocation, and so much more.
Links:
Any xamarin bluetooth example project? without using any plugin?
Any xamarin Bluetooth example project? without using any plugin?
Push notifications not being received by iOS application
I have been trying to set up push notifications for an iOS app using the PushSharp library. I have already successfully implemented push notifications with PushSharp for the Android version of the same app, with very few issues. However, despite closely following the examples on the Xamarin website, plus various others around the web I have only been able to get as far as registering the device; no notifications are being received.
So far I have:
1) Generated all the appropriate certificates and provisioning profiles.
2) Implemented overrides to RegisteredForRemoteNotifications, FailedToRegisterForRemoteNotifications & ReceivedRemoteNotification in my iOS app to handle registration and receipt of push notifications.
3) Implemented a call to the Apple Push Notification Server in my notification server (a .NET REST API) along the following lines:
Dim push As PushSharp.PushBroker = New PushSharp.PushBroker()
AddHandler push.OnNotificationSent, AddressOf NotificationSent
AddHandler push.OnChannelException, AddressOf ChannelException
AddHandler push.OnServiceException, AddressOf ServiceException
AddHandler push.OnNotificationFailed, AddressOf NotificationFailed
AddHandler push.OnDeviceSubscriptionExpired, AddressOf DeviceSubscriptionExpired
AddHandler push.OnDeviceSubscriptionChanged, AddressOf DeviceSubscriptionChanged
AddHandler push.OnChannelCreated, AddressOf ChannelCreated
AddHandler push.OnChannelDestroyed, AddressOf ChannelDestroyed
Dim appleCert As Byte() = File.ReadAllBytes(HttpContext.Current.Server.MapPath("~/bin/External/APNS-Certificate-Development.p12"))
push.RegisterAppleService(New ApplePushChannelSettings(False, appleCert, ""))
push.QueueNotification(New AppleNotification() _
.ForDeviceToken() _
.WithAlert(notificationMessage) _
.WithBadge(1) _
.WithSound("sound.caf"))
push.StopAllServices()
4) Ensured port 2195 is open for outgoing connections on the notification server.
5) Attempted to send notifications to an iPhone 5S & an iPad, both of which had the app running in the foreground when the attempt was made.
When my iOS app starts up it successfully registers for push notifications and this value is stored with the notification server. However, when the notification server sends a notification request to the Apple server, nothing is received on the iOS device. No exceptions are thrown on the notification server so it seems like the request succeeded but no notification is ever received.
Does anyone have any idea what I could be doing wrong, or any suggestions for other things I can try to get this working?
Many thanks,
Pat
TabbedPage event on tab click or refresh tab when same tab is clicked?
I'm using a TabbedPage with Xamarin.Forms, and when a user is already on Tab 2, and clicks on Tab 2, I'd either like that tab to reload, or i'd like to run my own custom code to refresh the page.
I have been trying to find any sort of event I could hook into, or a way to do this with custom renderers but have been unable to find anything. What's the simplest way to do this?
Thanks!
gps tracker in real time like uber or cabify
Hello guys,
I want to made an application that you can tracking people in real time like UBER or Cabify, I don't know how can I do this, my Idea is the follow
this is my idea but I dont know if this is the correct form, please can you please help me with this? anyon
Identifier Expected errors when binding a framework
I used objective sharpie to generate my ApiDefinition file and cleaned up the issues in there. When I import my framework into the project however, I get multiple errors in a couple of my *.g.cs files that say "Identifier Expect"
Here is an example of one of the lines that is causing the issue:
public static void RichEditorHeightDidChange (this IRichEditorDelegate This, global::.RichEditorView editor, NSObject height)
Is there something that I might have missed?
Custom ScrollView renderer does not work scroll
I create custom ScrollView.
This is done so that the swipes and scrolls work.
I need to make a vertical scroll.
Help me please
`
public class GestureScrollView : ScrollView
{
public event EventHandler SwipeDown;
public event EventHandler SwipeTop;
public event EventHandler SwipeLeft;
public event EventHandler SwipeRight;
public void OnSwipeDown() =>
SwipeDown?.Invoke(this, null);
public void OnSwipeTop() =>
SwipeTop?.Invoke(this, null);
public void OnSwipeLeft()
{
SwipeLeft?.Invoke(this, null);
}
public void OnSwipeRight()
{
SwipeRight?.Invoke(this, null);
}
}`
Android
`[assembly: ExportRenderer(typeof(GestureScrollView), typeof(Swipe.Droid.Platform.Renderers.GestureScrollViewRenderer))]
namespace Swipe.Droid.Platform.Renderers
{
public class GestureScrollViewRenderer : ScrollViewRenderer
{
readonly CustomGestureListener _listener;
readonly GestureDetector _detector;
public GestureScrollViewRenderer(Context context) : base(context)
{
_listener = new CustomGestureListener();
_detector = new GestureDetector(context, _listener);
}
public override bool DispatchTouchEvent(MotionEvent e)
{
if (_detector != null)
{
_detector.OnTouchEvent(e);
base.DispatchTouchEvent(e);
return true;
}
return base.DispatchTouchEvent(e);
}
public override bool OnTouchEvent(MotionEvent ev)
{
base.OnTouchEvent(ev);
if (_detector != null)
return _detector.OnTouchEvent(ev);
return false;
}
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement == null)
{
this.GenericMotion -= HandleGenericMotion;
this.Touch -= HandleTouch;
_listener.OnSwipeLeft -= HandleOnSwipeLeft;
_listener.OnSwipeRight -= HandleOnSwipeRight;
_listener.OnSwipeTop -= HandleOnSwipeTop;
_listener.OnSwipeDown -= HandleOnSwipeDown;
}
if (e.OldElement == null)
{
this.GenericMotion += HandleGenericMotion;
this.Touch += HandleTouch;
_listener.OnSwipeLeft += HandleOnSwipeLeft;
_listener.OnSwipeRight += HandleOnSwipeRight;
_listener.OnSwipeTop += HandleOnSwipeTop;
_listener.OnSwipeDown += HandleOnSwipeDown;
}
}
void HandleTouch(object sender, TouchEventArgs e)
{
_detector.OnTouchEvent(e.Event);
}
void HandleGenericMotion(object sender, GenericMotionEventArgs e)
{
_detector.OnTouchEvent(e.Event);
}
void HandleOnSwipeLeft(object sender, EventArgs e)
{
var _gi = (GestureScrollView)this.Element;
_gi.OnSwipeLeft();
}
void HandleOnSwipeRight(object sender, EventArgs e)
{
var _gi = (GestureScrollView)this.Element;
_gi.OnSwipeRight();
}
void HandleOnSwipeTop(object sender, EventArgs e)
{
var _gi = (GestureScrollView)this.Element;
_gi.OnSwipeTop();
}
void HandleOnSwipeDown(object sender, EventArgs e)
{
var _gi = (GestureScrollView)Element;
_gi.OnSwipeDown();
}
}
public class CustomGestureListener : GestureDetector.SimpleOnGestureListener
{
private static int SWIPE_THRESHOLD = 100;
static readonly int SWIPE_VELOCITY_THRESHOLD = 100;
MotionEvent mLastOnDownEvent;
public event EventHandler OnSwipeDown;
public event EventHandler OnSwipeTop;
public event EventHandler OnSwipeLeft;
public event EventHandler OnSwipeRight;
public override bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
return base.OnScroll(e1, e2, distanceX, distanceY);
}
public override bool OnDown(MotionEvent e)
{
mLastOnDownEvent = e;
return true;
}
public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
Console.WriteLine("OnFling");
if (e1 == null)
e1 = mLastOnDownEvent;
float diffY = e2.GetY() - e1.GetY();
float diffX = e2.GetX() - e1.GetX();
if (Math.Abs(diffX) > Math.Abs(diffY))
{
if (Math.Abs(diffX) > SWIPE_THRESHOLD && Math.Abs(velocityX) > SWIPE_VELOCITY_THRESHOLD)
{
if (diffX > 0)
OnSwipeRight?.Invoke(this, null);
else
OnSwipeLeft?.Invoke(this, null);
}
}
else if (Math.Abs(diffY) > SWIPE_THRESHOLD && Math.Abs(velocityY) > SWIPE_VELOCITY_THRESHOLD)
{
if (diffY > 0)
OnSwipeDown?.Invoke(this, null);
else
OnSwipeTop?.Invoke(this, null);
}
return base.OnFling(e1, e2, velocityX, velocityY);
}
}
}`
Xaml:
<ctrl:GestureScrollView x:Name="gi"> ... </ctrl:GestureScrollView>
C#:
`gi.SwipeDown += (s, e) =>
{
DisplayAlert("Gesture Info", "Swipe Down Detected", "OK");
// scroll down
};
gi.SwipeTop += (s, e) =>
{
DisplayAlert("Gesture Info", "Swipe Top Detected", "OK");
// scroll top
};
gi.SwipeLeft += (s, e) =>
{
DisplayAlert("Gesture Info", "Swipe Left Detected", "OK");
((NewsFeedDetailPageModel)BindingContext).OpenSourceCommand.Execute(null);
};
gi.SwipeRight += (s, e) =>
{
DisplayAlert("Gesture Info", "Swipe Right Detected", "OK");
((NewsFeedDetailPageModel)BindingContext).BackCommand.Execute(null);
};`
Maps, Current Location & Xaml
I wouldn't think that I'm the first to ask this.... but how can you set the current location in Xaml while using a View Model? I've searched & found out that I have to use an external GeoLocator (XLabs) & then the only way I'm seeing how to set the current location in the map is through code behind. Is this correct?
Steve.
How To implement Move to Region in xamarin forms google map MVVM
I want to Update map position and move to region when user select specific city
I do that but no thing changed
this is my code
Location.xaml.cs
public partial class LocationPage : ContentPage
{
public static BindableMap StoresMap;
public LocationPage()
{
StoresMap = LocationMap;
InitializeComponent();
}
}
Note : BindableMap is Custom Render form Map and i Used Google Map for this
and in view model
MabPosition = new Position(24.774265, 46.738586);
var Loc = StoresAddresses.FirstOrDefault();
LocationPage.StoresMap.MoveToRegion(new MapSpan(MabPosition, 24.774265, 46.738586));
what's the problem ?
Possible to automate switching icons for Xamarin.Forms project?
Hi,
We have a single project that is used by 2 different clients. The Apple store won't let us use the same icon for both, so we need to build version A with Icon set A, and then the same code as version B but with Icon B. Do you see any way to automate switching the icons?
Thanks!!
jesse
Xamarin.Form Image not showing in Imagecell
Hi i have seen some form where people having problem with picture not showing up when they add them to the ImageCell
I even print out my image string so i can look if something is wrong.
If i go back some versions of Xamarin.Form the http... links works but still not the image on the device. Newest version is from (24 Jan 2019)
The image shows if i do this...
<ListView.ItemTemplate>
</ListView.ItemTemplate>
The images is in default project (not android / ios) and i have a folder called Product there. and this works
_MainLayout.Children.Add(new Image { Source = ImageSource.FromResource("Inkopslista.Product.1.jpg") });
is this a problem, do i need to have them in andorid drawings to get the Imagecell to work?
xamarin studio 5.9.5 menus grayed out
Please can someone tell me what is wrong here as i have just installed xamarine studio on my aptop using a windows10 64bit operating system but cant run my project as the run menu is grayed out ,please what is the way foreward ?
can't build Marshmallow app using just the Xamarin.Forms xaml template
Not trying to do anything unusual or otherwise exotic. Just using VS 2017 (15.9.6) to build an app that runs on my Marshmallow (v6.0) phone. The app in question is nothing more than the default "Welcome to Xamarin.Forms!". After a 2 day ordeal I finally was able to deploy the app to my phone where it promptly threw an exception:
01-31 10:07:56.664 32388 32388 E AndroidRuntime: Process: com.companyname.App1.Android, PID: 32388
01-31 10:07:56.664 32388 32388 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_27 or Xamarin.Android.Platform!
Is VS 2017 not honoring the minimum target framework (which is set to v6.0) when generating the apk? It ran fine in the VisualStudio_Android-23_arm_phone emulator so what gives? There are a lot of devices running Marshmallow - it isn't that old. How do I build an app that runs on an Android Marshmallow device?
Question about Xamarin
Hello guys, I am new in this domain and I want to ask you how can I start to make an android app using Xamarin? I had the VS 2013 installed because I used it (we learn the C# at our school) and I understood that for creating android apps I need to install the Visual Studio 2017. I installed it and uninstalled several times because I simply did not understand how can I start the project.
When I select New proect -> Android -> Android App (Xamarin), there is already something written in the project .cs and it contains a lot of errors. And more than that, I don't find the "Main.axml" how I saw on youtube at guys that were making simple apps. Instead of it, I have "activity_main.axml" and "content_main.axml".
Other thing I saw on youtube was that the guys when they clicked New Project and Android, they had a lot of possibilities to choose from, including "Blank App (Android)", and I don't have that. I have only 5 possibilities:
i.imgur.com/B8y6dQG.png
So, can you help me to begin? I want you only to show me how to start the project..
And, one more thing.. As I said earlier, I don't know a lot of Xamarin, but the process of creating apps is the same like the process of creating windows forms? (for instance) I mean at VS 2013 with drag&drop items on the designer tab, with properties of the elements, with events etc?
Changing a specific value in a list during runtime.
Hello everyone,
I have a simple Xamarin.Android-App.
On the Activity of this app, there is a list displayed. Please see following MyActivity.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android ="http://schemas.android.com/apk/res/android"
android:orientation ="vertical"
android:layout_width ="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width ="match_parent"
android:layout_height="wrap_content"
android:text ="Click Me"
android:layout_marginTop ="20dp"
android:layout_marginLeft ="25dp"
android:layout_marginRight ="25dp"
android:id="@+id/button" />
<Space
android:layout_width="match_parent"
android:layout_height="25dp"
android:id="@+id/space" />
<ListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list" />
</LinearLayout>
One row of this list contains simply two entries, please see ListRow.axml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft ="5dp"
android:layout_marginTop ="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight ="5dp" />
<TextView
android:id="@+id/value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft ="5dp"
android:layout_marginTop ="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight ="5dp" />
</RelativeLayout>
So the code-behind of that activity looks like the following:
public class MyActivity : Activity
{
List<Entry> List = null;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MyActivity);
List = PopulateList();
var lv = FindViewById<ListView>(Resource.Id.list);
var adapter = new ListAdapter(this, Resource.Layout.List, List);
lv.Adapter = adapter;
FindViewById<Button>(Resource.Id.button).Click += OnButtonClick;
}
}
For the sake of completeness, here is the code for my ListAdapter.cs-class:
class ListAdapter : ArrayAdapter
{
List<Entry> List;
public ListAdapter(Context Context, int ListId, List<Entry> List) : base(Context, ListId, List)
{
this.List = List;
}
public override int Count
{
get { return List.Count; }
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
v = inflater.Inflate(Resource.Layout.List, parent, false);
}
v.FindViewById<TextView>(Resource.Id.name).Text = List[position].Name;
v.FindViewById<TextView>(Resource.Id.value).Text = "Original Value";
return v;
}
}
So my question now is the following: Assuming that there is more than one item within that List. On click of the button, I want to change one specific text within that list. Let's say of the second entry in the list the (Resource.Id.value).Text (which now says "Original Value") to "Changed Value" or something like that. But only of the second one. All the other items should stay the same.
Please see following scenario, maybe it's easier to understand what I am trying to do:
Name | Value |
Item Number 1 | Original Value |
Item Number 2 | Original Value |
Item Number 3 | Original Value |
[Button Click]
Name | Value |
Item Number 1 | Original Value |
Item Number 2 | Changed Value |
Item Number 3 | Original Value |
Can anyone maybe help me / tell me how to do this? What does my private void OnButtonClick(object sender, EventArgs e)
-method have to look like? How can I access a single entry in that list?
Thanks in advance for all answers and best regards