I have an android xamarin project, and I only add Xamarin.GooglePlayServices.Maps nuget.
my build has this error :
error: package com.google.android.gms.maps does not exist com.google.android.gms.maps.OnMapReadyCallback
I have an android xamarin project, and I only add Xamarin.GooglePlayServices.Maps nuget.
my build has this error :
error: package com.google.android.gms.maps does not exist com.google.android.gms.maps.OnMapReadyCallback
Can anyone help me on this How to add entry control dynamically and how to read the data entered in to that entry in xamarin forms If you have any sample Please send me.
Thanks.
If I open the application by clicking on the notification (got from Google Cloud Messaging), I doesn't get splash-screen
using Android.App;
using Android.Content;
using Android.OS;
using Android.Gms.Gcm;
using Android.Util;
using System;
using Android.Database.Sqlite;
namespace Dharma.Droid
{
[Service (Exported = false), IntentFilter (new [] { "com.google.android.c2dm.intent.RECEIVE" })]
public class MyGcmListenerService : GcmListenerService
{
public override void OnMessageReceived (string from, Bundle data)
{
var message = data.GetString ("message");
Log.Debug ("MyGcmListenerService", "From: " + from);
Log.Debug ("MyGcmListenerService", "Message: " + message);
DataAccess.InsertDowload (message);
SendNotification (message);
}
void SendNotification (string message)
{
var intent = new Intent (this, typeof(MainActivity));
intent.AddFlags (ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);
var notificationBuilder = new Notification.Builder (this)
.SetSmallIcon (Resource.Drawable.mhu2)
.SetContentTitle ("Mobile Health Unit")
.SetContentText ("U heeft een nieuwe vragenlijst.")
.SetAutoCancel (true)
.SetContentIntent (pendingIntent);
var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify (0, notificationBuilder.Build());
}
}
}
using Android.App;
using Android.Content;
using Android.Gms.Gcm.Iid;
namespace Dharma.Droid
{
[Service(Exported = false), IntentFilter(new[] { "com.google.android.gms.iid.InstanceID" })]
class MyInstanceIDListenerService : InstanceIDListenerService
{
public override void OnTokenRefresh()
{
var intent = new Intent (this, typeof (RegistrationIntentService));
StartService (intent);
}
}
}
using System;
using Android.App;
using Android.Content;
using Android.Util;
using Android.Gms.Gcm;
using Android.Gms.Gcm.Iid;
namespace Dharma.Droid
{
[Service(Exported = false)]
class RegistrationIntentService : IntentService
{
static object locker = new object();
public RegistrationIntentService() : base("RegistrationIntentService") { }
protected override void OnHandleIntent (Intent intent)
{
try
{
Log.Info ("RegistrationIntentService", "Calling InstanceID.GetToken");
lock (locker)
{
var instanceID = InstanceID.GetInstance (this);
var token = instanceID.GetToken (
"***************", GoogleCloudMessaging.InstanceIdScope, null);
Log.Info ("RegistrationIntentService", "GCM Registration Token: " + token);
SendRegistrationToAppServer (token);
Subscribe (token);
}
}
catch (Exception e)
{
Log.Debug("RegistrationIntentService", "Failed to get a registration token");
return;
}
}
void SendRegistrationToAppServer (string token)
{
}
void Subscribe (string token)
{
var pubSub = GcmPubSub.GetInstance(this);
pubSub.Subscribe(token, "/topics/global", null);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Support.V7.App;
using Android.Util;
using System.Threading.Tasks;
using Android.Gms.Common;
namespace Dharma.Droid
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof (SplashActivity).Name;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
}
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() =>
{
Task.Delay(5000); // Simulate a bit of startup work.
});
startupWork.ContinueWith(t =>
{
NetworkDiscovery network = new NetworkDiscovery();
CredentialsService cs = new CredentialsService();
if (GetToken() && network.IsOnline())
{
StartActivity(typeof (MainActivity));
}
else
{
StartActivity(typeof (NoInternetActivity));
}
}, TaskScheduler.FromCurrentSynchronizationContext());
startupWork.Start();
}
public bool GetToken()
{
if (IsPlayServicesAvailable ())
{
var intent = new Intent (this, typeof (RegistrationIntentService));
StartService (intent);
return true;
}
else
{
return false;
}
}
public bool IsPlayServicesAvailable ()
{
int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable (this);
if (resultCode != ConnectionResult.Success)
{
return false;
}
else
{
return true;
}
}
}
}
how to write userdialogs ActionSheetAsync cancel button event
UserDialogs.Instance.ActionSheetAsync("Title","Cancel","Ok",evente());
private CancellationToken? evente()
{
return null;
}
I had this working at one point but unable to get to a working state again.
My below code is always returning null and for the life of me I can't figure out why.
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Plugin.Media;
private async void UploadPhoto_Clicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();
var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
CompressionQuality = 50,
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Large
});
if (file == null)
return;
db.uploadBlob(System.IO.Path.GetFileName(file.Path), (System.IO.FileStream)file.GetStream(), "photos");
await DisplayAlert("Success", "Photo Uploaded :-)", "OK");
}
I have added the below into my MainActivity
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
This is also happening for the other CrossMedia calls such as PickPhotoAsync, TakeVideoAsync and PickVideoAsync. I have Version 2.6.2 of Plugin.Media installed.
Thanks in Advance
Luke
I'm wondering how to avoid delation after Navigation.PushAsync() was called. Where do I need to post all my initialization code for view and view model? At a moment my init code is in constructors of view and view model classes and my app has a delay of about half a second before push animation starts.
P.S. Using iOS
EDIT: Xamarin Studio version: Version 4.2.2 (build 2)
Hi guys,
Im looking to release a new version of my app that supports Xcode 5. Ive already released 1 app, but I have another app that uses some of the same units as the first (they are linked into the project). When I try to debug some code by placing a breakpoint, the output window shows 'Resolved pending breakpoint at XXX' text in the output window, but the app hangs and the breakpoint doesn't respond. Placing a breakpoint in another linked unit works fine. Both units are in the same project.
Ive tried the usual clean and rebuild, but no use. Any ideas?
Thanks
John
We're currently using Xamarin forms for an app where you can take a picture and store it on the database. We're using XF Labs (https://github.com/XForms/Xamarin-Forms-Labs) for the camera function and it's working great. Now, we only have to add a feature where the user can crop the photo they take or the one from the album. Problem is I don't have any idea how to create or call the native image cropping overlay for Photos that is usually used in iOS and Android.
I've seen Mike Bluestein create a crop overlay using a custom renderer for iOS here: http://blog.xamarin.com/using-custom-uiviewcontrollers-in-xamarin.forms-on-ios/ . But can this be recreated in Android? Or is there a way to call the native cropping function for cameras using custom renderers for both platforms?
I've done a lot of researching and also tried Mike's way for iOS. Just wanted some more insights. Thank you! 
I'm having a code design issue that I've been able to work around until now, but I've come to realise it can't possibly be the right solution. Hopefully someone can provide me with a better fix.
In my previous scenarios, I have loaded the LaunchScreen.xib as a viewcontroller and used that "after launch" to display while I'm doing the async work. And then once that finished, I show the real app. That way I can "fake" a second more of loading, while I perform the async work to determine whether to show a login screen, or the "logged in" screen.
While this works, it doesn't give me the smooth transition from the launchscreen to the app (because it "smoothly" transitions from the launch screen to a viewcontroller that looks exactly alike), and I'm sure there are other potential issues I simply haven't encountered yet.
So my question is, how do you all perform asynchronous work on launch, to determine things (for instance, login state)?
ContextCompatApi23.getColor
Java.Lang.RuntimeException: Attempt to invoke virtual method 'int android.content.Context.getColor(int)' on a null object reference
why I get this crash and what dose it mean
Hi,
I have a listview with a switch on each row, I want to flick the switch to select rows. All is fine except when I click one switch, others further down are selected eg. flicking switch on row 1 cause the switches on rows 1 + 9 + 17 etc. to be selected. What the heck is going on here?
<ListView x:Name="lstAssets"
ItemTapped="lstAssets_ItemTapped"
CachingStrategy="RecycleElement"
HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<Label Text="{Binding ID}" Style="{StaticResource lvMainLabel}" Grid.Row="0" Grid.Column="0" />
<Switch x:Name="swSelected"
Grid.Row="0" Grid.Column="1" >
</Switch>
<Label Text="{Binding Desc}" Style="{StaticResource lvDetailLabel}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" />
</Grid>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Hi there,
I´m using Visual Studio 2015 on Win 10 and a Macbook Air as Xamarin-Mac-Agent. When I´m running debug-Builds on the simulator or real devices the app works just fine. Doesn´t crash and has an icon. When I´m building an IPA and try to install it via iTunes it will get installed but doesn´t have the correct icon (just the white standard icon with the black lines across) and crashes right after launching. I came across that error because the version of app got rejected by apple so I tried to install it via iTunes.
I published a few other versions of the same app before which worked perfectly but now the build-process seems to be broken. The IPA is bigger now (58M to 40M before with almost no changes to the last build). Xamarin got updated (between the last build that was working and today) quite a few times so maybe that´s the problem? Maybe Win10 and MacOS aren´t in sync?
Did anybody come across that problem also and knows what I´m doing wrong?
Thank you,
Benjamin
I am not sure where to post this, but the Forum seems to be the most appropriate place..
Let me start to say that I am a fan of Xamarin and have been using Xamarin Studio for over 3 years now. We have a couple of apps in the IOS and Google Play app store and would like to continue with the product. Since we are developing in C# Xamarin seemed to be the logical choice.
So far the good news..
Recently we have started to use the more "advanced" features of Visual Studio for Mac. We needed to develop a new app for both IOS and Android and already quite early on in the process it turned out that Xamarin Forms was not the right way forward. The app did not give the IOS "feeling" on IOS and neither the "Android" feeling on "Android". Our experience is that Xamarin Forms is perhaps okay for simple applications, but anything sophisticated needs a more native approach. Apart from this experience we lost a lot of time because of bugs in Xamarin.
In the next iteration we split the app in a common part and two specific UI projects. To be a bit more "modern" than our previous apps, which uses separate XIBS for the UI we decided to go for a storyboard. With hindsight we should not have done this. The Xamarin Storyboard editor is so buggy that is is almost impossible to work with. Controls suddenly disappear, Code behind code is inconsistent, Deletion of object does not delete everything. It really feels like "developing by trial and error", something that I explicitly teach my younger colleagues not to do! On a number of occasions it was necessary to switch to Xcode Interface Builder to resolve some problems.
I understand that I cannot express this general quirkiness in a single support ticket and also that if I did a support engineer would not have a clue where to start resolving it. Being a software producer myself I also know how important this "general feeling of unreliability" is for a product, even when it is maybe only attributable to a handful of bugs.
It would be very good if Xamarin would do some user observation to see how the product is used in practice and how often Visual Studio responds in imcomprehensive ways. We would definitely volunteer to be the guinea pig ;-)
Now seriously: at this moment in time I think that Visual Studio for Mac is not suitable for professional software development and would urge Microsoft and Xamarin to do something about this. I would like to know how Microsoft would address this and also would like to see feedback from other users on this topic.
Kindest regards
Bert Degenhart Drenth
CTO Axiell Group
b.degenhartdrenth@axiell.com
I saw a lots of tutorials on xamarim web site and on google, not luck till now.
All examples are portions of code and almost all has deprecated code for iO6.
Does anyone has a step by step guide showing how to do that, or even a example solution that, I can click on a button and call the video camera to starts to record?
Hi, i have the problem of xamarin.ios does not support running or debugging the previous built version of your project,I'm working on Visual Studio 2015 on Windows and I have this problem, I already search for a solution but I didn't find one, what can I do?
This is a pic of the error

Is it possible to run UI tests on multiple devices locally at the same time?
Looking for some help using the camera in a xamarin forms pcl application. not really finding much information online. Even a tutorial link would be helpful.
Hi,
I've been searching and trying a lot of solution and today, in 2017, I feel like no one could create a Camera Control that can be used as a simple button?
In the many solutions I tried, either the camera doesn't show up or doesn't fully fit the screen, why?
I'm just trying to create a CameraView or CameraControl that show a preview and has method option as TakePicture, TakeVideo.
Because, the problem with most of the solution, it's that you can't design around, like put some text or some design...
Does anyone have an explanation or some tips/idea? Or just maybe a solution? Because, to me, it's impossible that today, no one is able to make a cross platform solution of that.. doesn't it?
Hi,
I want to add Checkbox control in Xaml page. I added below code in .Xaml page.
<CheckBox Margin="10, 10, 3, 3"
Name="acceptPolicy"
Content = "Accept our policy"
FontSize="12"
Checked="CheckBox_Checked"/>
But i am getting below error?
Error CS0246: The type or namespace name 'CheckBox' could not be found (are you missing a using directive or an assembly reference?)
I am new to Xaml, since i am unable to find Checkbox control in Xamarin.Forms Xaml, i tried to use default Checkbox from here.
If some controls doesn't exist in Xamarin.Forms Xaml, whether can i use default Xaml controls or not?
I have a Xamarin Forms app (2.3.4+) with AdMob ads. I can see banners and interstitials in both Android and iOS apps. I'd like to enable AdMod mediation to show also Facebook ads, but mediation is not working.
Everything is configured server side. I've configured Facebook and Google, following the respective guides. I can see Facebook banners and interstitials if in the app I show them directly via the Facebook APIs and not via Google AdMob.
I guess the problem is app side. When I call InterstitialAd.Show() only AdMob banners are shown. For testing purpose I've set eCPM = 200$ to force Google to serve FB ads:

On the AdMob dashboard I see the N requests yet 0 impressions for Facebook:

In the logs I see:
07-06 12:54:13.390 I/Ads (29542): Starting ad request.
07-06 12:54:13.395 I/Ads (29542): Use AdRequest.Builder.addTestDevice("XXX") to get test ads on this device.
07-06 12:54:15.817 I/Ads (29542): Trying mediation network: https://googleads.g.doubleclick.net/aclk?sa=...
07-06 12:54:15.831 I/Ads (29542): Instantiating mediation adapter: com.google.ads.mediation.facebook.FacebookAdapter
07-06 12:54:15.836 I/Ads (29542): Trying mediation network:
07-06 12:54:15.844 I/Ads (29542): Instantiating mediation adapter: com.google.ads.mediation.admob.AdMobAdapter
07-06 12:54:15.848 W/Ads (29542): Server parameters: {"pubid":"ca-app-pub-XXX\/cak=no_cache&cadc=wb&caqid=YYY","gwhirl_share_location":"1"}
07-06 12:54:18.509 I/Ads (29542): Ad finished loading.
07-06 12:54:18.722 I/Ads (29542): Ad opening.
I'm using these packages:
// Android
<package id="Xamarin.GooglePlayServices.Ads" version="42.1021.1" targetFramework="monoandroid71" />
<package id="Xamarin.GooglePlayServices.Ads.Lite" version="42.1021.1" targetFramework="monoandroid71" />
<package id="Xamarin.Facebook.Android" version="4.22.0" targetFramework="monoandroid71" />
<package id="Xamarin.Facebook.AudienceNetwork.Android" version="4.22.0" targetFramework="monoandroid71" />
// iOS
<package id="Xamarin.Google.iOS.MobileAds" version="7.16.0" targetFramework="xamarinios10" />
<package id="Xamarin.Facebook.AudienceNetwork.iOS" version="4.24.0" targetFramework="xamarinios10" />
<package id="Xamarin.Facebook.iOS" version="4.24.0" targetFramework="xamarinios10" />
Any idea on why Facebook are never served by AdMob?
Thanks