Xamarin Android popupwindow - crashes when inflated - xamarin

I'm trying to create a pop up window that shows a clock (actually what i want is a countdown timer but one thing at a time!), the trouble is when i call the method to show the pop up window containing the clock, the app crashes.
The method is being called from an Activity not a fragment.
Here is the code:
public void clockPopup()
{
LayoutInflater inflater =(LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View myPopup = inflater.Inflate (Resource.Layout.PopUpClockTimer, null);
RunOnUiThread (() => {
PopupWindow popup = new PopupWindow (myPopup);
});
}
The stack trace is as follows:
[mono] Unhandled Exception:
[mono] Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
[mono] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
[mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in <filename unknown>:0
[mono] at Android.Views.LayoutInflater.Inflate (Int32 resource, Android.Views.ViewGroup root) [0x00000] in <filename unknown>:0
[mono] at FrogPoint.Droid.MainActivity.clockPopup () [0x00020] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:1548
[mono] at FrogPoint.Droid.MainActivity+<getBeaconData>c__async3.MoveNext () [0x00258] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:1215
[mono] --- End of stack trace from previous location where exception was thrown ---
[mono] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
[mono] at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
[mono] at FrogPoint.Droid.MainActivity+<RangingBeaconsInRegion>c__async0.MoveNext () [0x0035d] in /Users/jakememery/Desktop/working Frogpoint/FrogPoint1.2_database/FindTheMonkey.Droid/MainActivity.cs:675
[mono] --- End of managed exception stack trace ---
[mono] android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.AnalogClock
[mono] at android.view.LayoutInflater.createView(LayoutInflater.java:620)
[mono] at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
[mono] at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
[mono] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[mono] at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
[mono] at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
[mono] at dalvik.system.NativeStart.run(Native Method)
[mono] Caused by: java.lang.reflect.InvocationTargetException
[mono] at java.lang.reflect.Constructor.constructNative(Native Method)
[mono] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[mono] at android.view.LayoutInflater.createView(LayoutInflater.java:594)
[mono] ... 10 more
[mono] Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
[mono] at android.os.Handler.<init>(Handler.java:200)
[mono] at android.os.Handler.<init>(Handler.java:114)
[mono] at android.widget.AnalogClock.<init>(AnalogClock.java:57)
[mono] at android.widget.AnalogClock.<init>(AnalogClock.java:67)
Here is the XML i'm trying to inflate:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/customborder"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/textout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time sensitive offer" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/logo76" />
<AnalogClock
android:id="#+id/tabAnalogClock"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<DigitalClock
android:id="#+id/tabDigitalClock"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="#+id/dismiss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dismiss" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Can anybody see where i'm going wrong here please?

It seems i simply needed to call the method like this:
RunOnUiThread (() => {
clockPopup();
});
It doesn't crash now. But unfortunately neither does it display the pop up. But that's for another post.

You are missing either:
popup.ShowAtLocation(...);
or
popup.ShowAsDropDown(...);
to actually display the popup window.

Related

Unable to build Xamarin Android Application in Release Mode

I am trying to build Xamarin Forms Android App but it's not getting compiled in Release mode, while Debug works fine.
Error Detail:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5):
Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.Steps.XmlResolutionException: Failed to process XML
description: --->
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly:
'Prism.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Prism.Core, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' at Mono.Cecil.BaseAssemblyResolver.Resolve
(Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters
parameters) [0x0015e] in
/Users/builder/data/lanes/6102/8255f42f/source/monodroid/external/xamarin-android/external/mono/external/cecil/Mono.Cecil/BaseAssemblyResolver.cs:172
at Mono.Linker.AssemblyResolver.Resolve
(Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters
parameters) [0x0005c] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope)
[0x00007] in <947dd92f52fa43c1922f96c7b9774bdc>:0 --- End of inner
exception stack trace --- at Mono.Linker.LinkContext.Resolve
(Mono.Cecil.IMetadataScope scope) [0x00030] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.GetAssembly
(Mono.Linker.LinkContext context, Mono.Cecil.AssemblyNameReference
assemblyName) [0x00000] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies
(Mono.Linker.LinkContext context, System.Xml.XPath.XPathNodeIterator
iterator) [0x00010] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.ResolveFromXmlStep.Process () [0x00037] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 --- End of inner exception
stack trace --- at Mono.Linker.Steps.ResolveFromXmlStep.Process ()
[0x000a9] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context)
[0x00010] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context)
[0x0001c] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
MonoDroid.Tuner.Linker.Run (Mono.Linker.Pipeline pipeline,
Mono.Linker.LinkContext context) [0x00000] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
MonoDroid.Tuner.Linker.Process (MonoDroid.Tuner.LinkerOptions options,
Mono.Linker.ILogger logger, Mono.Linker.LinkContext& context)
[0x00071] in <947dd92f52fa43c1922f96c7b9774bdc>:0 at
Xamarin.Android.Tasks.LinkAssemblies.Execute
(Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x002d4] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Xamarin.Android.Tasks.LinkAssemblies.Execute () [0x0021f] in
<947dd92f52fa43c1922f96c7b9774bdc>:0 at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute
() [0x00023] in
/Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask
(Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost,
Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext,
Microsoft.Build.BackEnd.TaskHost taskHost,
Microsoft.Build.BackEnd.ItemBucket bucket,
Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6]
in
/Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
(MSB4018) (VSTSBuild.Droid)
Also I noticed that it's building in Release mode as well if I enable 'Use Shared Mono Runtime' but if it's disabled then I am having issue building the solution.
Okay, I found out that issue was with LinkerSettings. Previously my Linker Settings was like this:
<linker>
<assembly
fullname="Prism.Core" />
<assembly
fullname="Prism.Forms" />
<assembly
fullname="Prism.Unity.Forms" />
<assembly
fullname="Prism.Plugin.Popups" />
</linker>
Which I updated to:
<linker>
<assembly
fullname="Prism.Forms">
<type
fullname="Prism.Common.ApplicationProvider"
preserve="all" />
<type
fullname="Prism.Services.PageDialogService"
preserve="all" />
<type
fullname="Prism.Services.DeviceService"
preserve="all" />
<type
fullname="Prism.Ioc*"
preserve="all" />
<type
fullname="Prism.Modularity*"
preserve="all" />
<type
fullname="Prism.Navigation*"
preserve="all" />
<type
fullname="Prism.Behaviors.PageBehaviorFactory"
preserve="all">
<method
name=".ctor" />
</type>
<type
fullname="Prism.Services.DependencyService"
preserve="all">
<method
name=".ctor" />
</type>
</assembly>
<assembly
fullname="Prism">
<type
fullname="Prism.Navigation*"
preserve="all" />
<type
fullname="Prism.Logging.EmptyLogger"
preserve="all">
<method
name=".ctor" />
</type>
</assembly>
</linker>
Now App is building fine in Release mode as well.

Xamarin Android Background Location Service null

I used this demo to use background location services for my Android project (since Geolocator wouldn't background on Android). I haven't had any problems until yesterday when it gave me the following error:
[ServiceConnection] OnServiceConnected Called
Service Connected
[LocationService] You are about to get location updates via
[Mono] Assembly Ref addref Mono.Security[0xa7dd6ba0] -> System[0xadd5aac0]: 15
[Mono] DllImport attempting to load: '/system/lib/liblog.so'.
[Mono] DllImport loaded library '/system/lib/liblog.so'.
[Mono] DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
[Mono] Searching for '__android_log_print'.
[Mono] Probing '__android_log_print'.
[Mono] Found as '__android_log_print'.
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.IllegalArgumentException: invalid provider: null
[MonoDroid] at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <ab9e0fea7db841c1a1450c120052eb14>:0
[MonoDroid] at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <ab9e0fea7db841c1a1450c120052eb14>:0
[MonoDroid] at Android.Locations.LocationManager.RequestLocationUpdates (System.String provider, System.Int64 minTime, System.Single minDistance, Android.Locations.ILocationListener listener) [0x0007e] in <21f1b0b5ad7242d7afaeceae3e6dbac8>:0
[MonoDroid] at Divco.LocationService.StartLocationUpdates () [0x0003c] in /Users/ediewoelfle/Developer/ancient-bastion-mobile/Droid/Services/LocationService.cs:78
[MonoDroid] at Divco.LocationServiceConnection.OnServiceConnected (Android.Content.ComponentName name, Android.OS.IBinder service) [0x0004f] in /Users/ediewoelfle/Developer/ancient-bastion-mobile/Droid/Services/LocationServiceConnection.cs:42
[MonoDroid] at Android.Content.IServiceConnectionInvoker.n_OnServiceConnected_Landroid_content_ComponentName_Landroid_os_IBinder_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_name, System.IntPtr native_service) [0x00019] in <21f1b0b5ad7242d7afaeceae3e6dbac8>:0
[MonoDroid] at (wrapper dynamic-method) System.Object.31(intptr,intptr,intptr,intptr)
[MonoDroid] --- End of managed Java.Lang.IllegalArgumentException stack trace ---
[MonoDroid] java.lang.IllegalArgumentException: invalid provider: null
[MonoDroid] at android.location.LocationManager.checkProvider(LocationManager.java:2317)
[MonoDroid] at android.location.LocationManager.requestLocationUpdates(LocationManager.java:490)
[MonoDroid] at md587a0a65fe57ffee4ef3988209babfc12.LocationServiceConnection.n_onServiceConnected(Native Method)
[MonoDroid] at md587a0a65fe57ffee4ef3988209babfc12.LocationServiceConnection.onServiceConnected(LocationServiceConnection.java:38)
[MonoDroid] at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1535)
[MonoDroid] at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1563)
[MonoDroid] at android.os.Handler.handleCallback(Handler.java:751)
[MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:95)
[MonoDroid] at android.os.Looper.loop(Looper.java:154)
[MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:6316)
[MonoDroid] at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
[MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="42" android:versionName="0.1" package="com.divcodelivery.divco">
<uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application android:label="Divco" android:icon="#drawable/logo_size_icon">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.divcodelivery.divco.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
</application>
</manifest>
I have located the null locationProvider, however, I am unsure WHY.

Why does setting a style for StackLayout result in a NullReferenceException?

I want each Entry type in my in my StackLayout to have a margin. I'm trying to specify a style as follows:
<StackLayout IsVisible="{Binding IsLoggingIn, Converter={StaticResource BooleanConverter}}">
<StackLayout.Resources>
<Style TargetType="{x:Type Entry}">
<Setter Property="Margin" Value="0,0,0,20"/>
</Style>
</StackLayout.Resources>
<Entry ... />
<Entry ... />
</StackLayout>
Unfortunately, it results in a NullReferenceException:
04-13 16:26:15.406 E/mono (17167): Unhandled Exception:
04-13 16:26:15.406 E/mono (17167): System.NullReferenceException: Object reference not set to an instance of an object.
04-13 16:26:15.406 E/mono-rt (17167): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
With a bit more stack trace for reference:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at MyApp.Views.Login.InitializeComponent () [0x00012] in C:\dev\PathTo\MyApp\obj\Debug\MyApp.Views.Login.xaml.g.cs:22
at MyApp.Views.Login..ctor () [0x00008] in C:\dev\PathTo\MyApp\Views\Login.xaml.cs:9
at MyApp.App.SetupLoginPage () [0x00001] in C:\dev\PathTo\MyApp\App.xaml.cs:94
at MyApp.App+<OnStart>d__4.MoveNext () [0x001ad] in C:\dev\PathTo\MyApp\App.xaml.cs:60
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35
at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81
at (wrapper dynamic-method) System.Object:d83972de-0492-4d07-a14d-24725ac1bfd1 (intptr,intptr)
What could be causing this, and how can I fix it? For the record, if I specify the margin inline e.g. <Entry margin="0,0,0,20"/>, it works fine.
I think your syntax is wrong. Shouldn't it be this;
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Entry">
<Setter Property="Margin" Value="0,0,0,20"/>
</Style>
</ResourceDictionary>
</StackLayout.Resources>
Note how I changed the TargetType and added the ResourceDictionary tag around it.

MvxGridView - crash when item template is set

I tried to use Mvx.MvxGridView but it crash when I set MvxItemTemplate with debug output message:
Could not find method android.widget.GridView.<init>, referenced from method cirrious.mvvmcross.binding.droid.views.MvxGridView.<init>
Crashing code:
<Mvx.MvxGridView
android:id="#+id/GridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource SomeSource"
local:MvxItemTemplate="#layout/itemtemplatepath"/>
Item template:
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/MyApp.Droid">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="top|center"
local:MvxBind="Text Member.FirstName"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
If MvxItemTemplate isn't set - then MvxGridView is rendered with default ItemTemplate (text with full class name). Any suggestions?
Ok my fault - it works but LinearLayout (every defined View) should have explicitly set "android:layout_width" and "android:layout_height".

Google maps api on User defined image

Would anyone please tell me if is it possible to use the functionalities of Google maps api (like focusing and zooming in) not on a map but on a user defined image( in .png or .jpeg formats). If yes, how to do it? I have been googling it for a couple of days but i cant get an exact answer for my question. Sorry for being silly but I am new to programming. Hope someone will help me.
xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<RelativeLayout
android:id="#+id/relative_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="45dp"
android:layout_marginRight="20dp" >
<ImageView
android:id="#+id/btn_zoom_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/btn_zoom_in" />
<ImageView
android:id="#+id/btn_zoom_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/btn_location"
android:src="#drawable/btn_zoom_out" />
<ImageView
android:id="#+id/btn_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/btn_zoom_in"
android:src="#drawable/btn_location" />
</RelativeLayout>
</RelativeLayout>
Your Activity:-
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_location:
map.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(location
.getLatitude(), location.getLongitude())));
break;
case R.id.btn_zoom_in:
map.animateCamera(CameraUpdateFactory.zoomIn());
break;
case R.id.btn_zoom_out:
map.animateCamera(CameraUpdateFactory.zoomOut());
break;
default:
break;
}
}
i hope it would solve your problem.... :)

Resources