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

App crashes after Sticky service is restarted

$
0
0

Hi,

I have simple service for working with local notifications - which works fine until user force closes it. After that, service should restart when Android has available resources, but when that happens, I get two dialogs stating that App has crashed and by look into app manager I can see that service didn't start again. The service looks like this:

  [Service]
    public class NotificationService:Service
    {
    public Intent intent;
    public PendingIntent pi;
    public AlarmManager am;
    public override Android.OS.IBinder OnBind (Intent intent)
    {
        return null;
    }


    [Obsolete ("deprecated")]
    public override StartCommandResult OnStartCommand (Intent intent, StartCommandFlags flags, int startId)
    {
        SetAlarms (DateTime.Now.AddSeconds(10));
        AlarmReceiver receiver = new AlarmReceiver ();
        return StartCommandResult.Sticky;
    }

    public void SetAlarms (DateTime? dateTime){
        intent = new Intent (Forms.Context,typeof(AlarmReceiver));
        intent.SetAction ("show_notification");
        pi = PendingIntent.GetBroadcast(Forms.Context,0, intent,0);
        am = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService);
        am.Set (AlarmType.RtcWakeup, (long)(Java.Lang.JavaSystem.CurrentTimeMillis () + (dateTime.Value.ToUniversalTime () - DateTime.Now.ToUniversalTime ()).TotalMilliseconds), pi);

    }
    public override void OnDestroy ()
    {
        am.Cancel (pi);
        am.Dispose ();
        intent.Dispose ();
        pi.Dispose ();
        base.OnDestroy ();
    }

Oh and also - I start it manually inside MainActivity's OnCreate using this code:

Intent ServiceIntent = new Intent(Forms.Context,typeof(NotificationService));
StartService (ServiceIntent);

Jar binding problem/confusion: Cannot find "private" methods converted result

$
0
0

We found a common confused problem is that those "private" methods in Jar cannot be converted through Xamarin.Droid Jar Binding project, so we got exception after conversion when running up APP and we got error and warning message in the VS2013 "output" window. We want to know why not converted by Xamarin, for we really need those methods? Attached the Jar (actually we successfully bind it but runs with exception from "com.sina.weibo.net.HttpManager") and the configured Metadata.xml file. Either, another question is we don't know whether the Xamarin convention logic can includes .so(C++ assembly files) files. Anyone who can kindly help? I would be much more appreciate.

Location and WiFi/4G

$
0
0

Hello all!

I have been using the Location Dependency to be able to locate a person on a Map for Android.
The map is working just fine, and when I try to get the location I have the following problem :
- When I activate the GPS, the location is returning
- When I don't activate the GPS but only the WiFi, or the 4G for that matter, it doesn't return me anything.

Here's the code that I am using :

    public class Mapfor_Android : Java.Lang.Object, ILocationListener, MapInterface
        {
            private LocationManager _locationManager;
            private string _locationProvider { get; set; }
        private Location _currentLocation { get; set; }

            Geocoder theCoder;  

    public Mapfor_Android()
    {
        this.InitializeLocationManager();
    }

    void InitializeLocationManager()
    {
        _locationManager = (LocationManager)Forms.Context.GetSystemService(Context.LocationService);
    }

    public void Start()
    {

            var criteriaForLocationService = new Criteria { Accuracy = Accuracy.NoRequirement, PowerRequirement = Power.NoRequirement };
            try
            {
                _locationProvider = _locationManager.GetBestProvider(criteriaForLocationService, true);
                System.Diagnostics.Debug.WriteLine(_locationManager.AllProviders);
                if (!string.IsNullOrEmpty(_locationProvider) && _locationManager.IsProviderEnabled(_locationProvider))
                {
                    _locationManager.RequestLocationUpdates(_locationProvider, 2000, 1, this);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("No (enabled) location provider available.");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

    }


    public void SetLocation()
    {
        var currentLocationString = _currentLocation == null 
                                        ? "Can't determine the current address." 
                                        : string.Format("{0} - {1}", _currentLocation.Latitude, _currentLocation.Longitude);

        MessagingCenter.Send<MapInterface, string> (this, Messaging.LocationUpdated, currentLocationString + " " + _locationProvider);
    }

    public void OnLocationChanged(Location location)
    {
        _currentLocation = location;
        SetLocation();
    }

    public void OnStatusChanged(string provider, Availability status, global::Android.OS.Bundle extras)
    {
        //Not Implemented
    }

    public void OnProviderDisabled(string provider)
    {
        //Not Implemented
    }

    public void OnProviderEnabled(string provider)
    {
        //Not Implemented
    }
}

By the way I have all the uses permissions needed ( ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION, etc...)

Thank you for your help! :)

June 16, 2015 - Nashville, TN - Building HistoriCrawl: Part 1

Binding to a string in a page

$
0
0

Hi,

I got this List I want to bind a string to be used in a Item view container, how is that possible?
And I am not talking about binding to labels and such, its going to be used for a Share button.
Thanks :)

Best Ali

App runs ok in simulator, runs OK in Debug mode on device, but crashes when published to device

$
0
0

This is a truly odd situation since it is impossible for me to debug because it runs OK in Debug mode !!!

The app consists of a Login page which contains a TableView, a TextField, and a Button. Users select their userID from the table, enter their pin number in the box, and press the login button. The ViewController has been designed in IB as a XIB file. All outlets have been included in the header .h file shown below:

// WARNING
// This file has been generated automatically by Xamarin Studio to
// mirror C# types. Changes in this file made by drag-connecting
// from the UI designer will be synchronized back to C#, but
// more complex manual changes may not transfer correctly.

import <Foundation/Foundation.h>

import <UIKit/UIKit.h>

@interface LoginPage : UIViewController {
UIActivityIndicatorView *_LoginBusyIndicator;
UIButton *_LoginButton;
UITextField *_UsersIDEntry;
UITableView *_UsersSelectionList;
}

@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *LoginBusyIndicator;

@property (nonatomic, retain) IBOutlet UIButton *LoginButton;

@property (nonatomic, retain) IBOutlet UITextField *UsersIDEntry;

@property (nonatomic, retain) IBOutlet UITableView *UsersSelectionList;

  • (IBAction)OnLoginCommand:(id)sender;

@end

The app crashed the minute I reference the Table, only when packed and installed in release mode into the iPad iOS V8

using System;
using System.Collections.Generic;
using Foundation;
using UIKit;
using TestAPP.Model; // local package
using TestAPP.Helper; // local package

namespace TestAPP
{
public partial class LoginPage : UIViewController
{
String[] empName;

    public LoginPage () : base ("LoginPage", null)
    {
    }

    public override void DidReceiveMemoryWarning ()
    {
        // Releases the view if it doesn't have a superview.
        base.DidReceiveMemoryWarning ();

        // Release any cached data, images, etc that aren't in use.
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        // Perform any additional setup after loading the view, typically from a nib.
    }

    public void Reset()
    {
        UsersIDEntry.Text = "";
        UsersIDEntry.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
    }

    // Called from ApplicationDelegate once all is initialised and ready
    public void PopulateEmployeesNames ( List<Employee> employeesData)
    {
        try
        {
            LoginBusyIndicator.StopAnimating ();
            LoginBusyIndicator.Hidden = true; 

            empName = new string[employeesData.Count];
            int index = 0;
            foreach (var employee in employeesData)
                empName[index++] = employee.check_name;
            // CRASHES HERE. Works OK if these 2 lines are removed
            ((UIKit.UITableView) UsersSelectionList).Source = new EmployeeLoginTableSource (empName);


            UsersSelectionList.ReloadData ();
        } catch (Exception e) {
            new UIKit.UIAlertView ("Error", "This never gets called!!!" + e.ToString(), null, "Continue").Show ();
        }
    }

    partial void OnLoginCommand(Foundation.NSObject sender)
    {
        //new UIKit.UIAlertView ("Yo!", "Error DUDE! Server sent some shit!!!", null, "Continue").Show ();
        AppDelegate _theAppDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate;
        _theAppDelegate.KillLoginAndSwapRootToMain();
    }
}

}

Below is the EmployeeLoginTaleSource

using System;
using System.Collections.Generic;
using System.IO;
using Foundation;
using UIKit;

namespace TestAPP.Helper
{
public class EmployeeLoginTableSource : UITableViewSource
{
string[] TableItems;
string cellIdentifier = "TableCell";

    public EmployeeLoginTableSource (string[] items)
    {
        TableItems = items;
    }

    public override nint NumberOfSections (UITableView tableview)
    {
        return 1;
    }

    public override nint RowsInSection (UITableView tableview, nint section)
    {
        return TableItems.Length;
    }

    public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
    {
        UITableViewCell cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
        string item = TableItems[indexPath.Row];

        cell.TextLabel.Text = item;

        return cell;
    }
}

}

Any ideas?

Gps and Heading

$
0
0

Hi folks,
I have a Forms app using Geolocator and everything works fine, except Heading on Android. The value returns always 0. On iOS it works without problems. Any suggestions ?

BR
Axel

Microsoft Office 365 Developing in iOS

$
0
0

I want to use office 365 in my project, but when i tried to add, i got this error

enter image description here

I have a xamarin.ios project but cant add it..

As here says I can use xamarin ios also

The following projet templates support adding Office 365 APIs as a
connected service: .NET Windows Store 8.1 Apps .NET Windows Store 8.1
Universal Apps .NET Windows Phone 8.1 Apps .NET Windows Phone 8.1
Silverlight Apps Windows Forms Applications WPF Applications ASP.NET
MVC Web Applications ASP.NET Web Forms Applications Xamarin Android
and iOS Applications Multi-device Hybrid (Cordova) Apps

https://msdn.microsoft.com/office/office365/HowTo/adding-service-to-your-Visual-Studio-project

I downloaded and installed OfficeToolsForVS2013Update1.exe

https://www.microsoft.com/web/handlers/WebPI.ashx/getinstaller/OfficeToolsForVS2013Update1.appids

and my visual studio version is VS 2013, update 4

so what can be problem?

PS: I created also a new ios blank project but still the same error.


IOS Simulator Not Loading

$
0
0

Hi,

I am new to Xamarin Studio and have the latest updates and latest xcode however when i try to launch to run the application on the simulator I get the following errors:

Starting iPhone 6
Failed to launch the simulator: Argument cannot be null.
Parameter name: obj
error MT1008: Failed to launch the simulator: Argument cannot be null.
Parameter name: obj

I have checked the preferences and Xamarin finds both the Ios SDK and the Xamarin.Ios correctly.

Any advice on how I can resolve this please?

Many thanks

Matt

Material Design in Xamarin.Forms

$
0
0

Hi All,
Just a quick question:

If I will do a Xamarin.Forms project will it look and behave like Material Design rules tells, when I will run it on Android 5 (Lollipop)?

Getting NullPointerException with AppCompatActivity after june 2nd update.

$
0
0

After June 2nd Xamarin platform update I'm getting NullPointerException, when AppCompatActivity starts.
Workaround is to use older version of Xamarin.Android. But I wanna know what's wrong.

[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
[MonoDroid] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x0004b>
[MonoDroid] at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029
[MonoDroid] at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:5466
[MonoDroid] at Divvy.Android.UI.Activities.SplashActivity.OnCreate (Android.OS.Bundle) [0x00009] in d:\Projects\divvyMobile\Divvy.Android\UI\Activities\SplashActivity.cs:22
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mavericks-monodroid-5.1-series/d419c934/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2707
[MonoDroid] at (wrapper dynamic-method) object.e2dd4570-1bf5-41c3-8251-c245e04b892f (intptr,intptr,intptr) <IL 0x00017, 0x00027>
[MonoDroid]   --- End of managed exception stack trace ---
[MonoDroid] java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.internal.widget.ContentFrameLayout.setId(int)' on a null object reference
[MonoDroid]     at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:389)
[MonoDroid]     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
[MonoDroid]     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
[MonoDroid]     at md5feaba49227f182b4a9f46be73a17f454.SplashActivity.n_onCreate(Native Method)
[MonoDroid]     at md5feaba49227f182b4a9f46be73a17f454.SplashActivity.onCreate(SplashActivity.java:31)
[MonoDroid]     at android.app.Activity.performCreate(Activity.java:5990)
[MonoDroid]     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
[MonoDroid]     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
[MonoDroid]     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
[MonoDroid]     at android.app.ActivityThread.access$800(ActivityThread.java:151)
[MonoDroid]     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
[MonoDroid]     at android.os.Handler.dispatchMessage(Handler.java:102)
[MonoDroid]     at android.os.Looper.loop(Looper.java:135)
[MonoDroid]     at android.app.ActivityThread.main(ActivityThread.java:5254)
[MonoDroid]     at java.lang.reflect.Method.invoke(Native Method)
[MonoDroid]     at java.lang.reflect.Method.invoke(Method.java:372)
[MonoDroid]     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
[MonoDroid]     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Activity code:

[Activity(MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait, NoHistory = true, Theme="@style/AppTheme.NoActionBar")]      
    public class SplashActivity : AppCompatActivity, IOnMapReadyCallback
    {
        protected override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            SetContentView (Resource.Layout.activity_splash);

            InitDatabase ();

            if (!string.IsNullOrEmpty (AccountUtils.GetCurrentUserSessionId (this)))
                StartActivity (typeof(HomeActivity));
            else
                StartActivity (typeof(LoginActivity));
        }
}

Components install windows loops on login

$
0
0

Whenever I try to install a new component (by clicking the "Add to App" button) the component store window redirects me to the login page where I type my Xamarin credentials and it brings me back to the component's page where the same thing happens again and again, thus I can't install any component. I managed to overcome the problem by downloading each component and referencing manually the DLL.

I tried to delete and reinstall Xamarin Studio but the problem's still there.

I attach a screenshot.

Thank you
Umar

Why do i receive "timed out" messages all time when playing the nexus 7/4/10 devices?

$
0
0

I really love this android emulator, but nobody answers me why when i try to initialize nexus 7, or 10, or 4, i always receive the message "Timed out, waiting for IP address" Can someone help me, I would really appreciate it!

Has Anyone Here Deployed A Commercial App Using Xamarin.Forms?

$
0
0

I am very intrigued with the promise of Xamarin Forms but before I start developing with it I am curious to know if there are any other Xamarin Forms applications out there in a production state.

Thanks

Droid sample does not run on OSX after installing Fresh Xamarin Trial

$
0
0

I just tried running the Droid project created when creating a empty project of type "Blank Xamarin Forms App" under "Cross Platform". I targeted both iOS Android and used a "Portable Class Library".

When I click "run" regardless of my emulator selection nothing starts, I just see this and no error messages.

image

Any ideas? I'm somewhat stuck...


Gesture support?

$
0
0

Hi!

I have tried Mr. Gestures and it won't cover my needs. I also tried to use the following with a custom renderer and can't seem to get it to work:
http://arteksoftware.com/gesture-recognizers-with-xamarin-forms/

Is there more support for gestures coming to Xamarin forms? At a minimum, I'd need the generic motion - the touch up and down events are not enough.

Thanks!
Mike

Is there something in Xamarin for Auto-Scrolling when KeyBoard Show and Hide ?

$
0
0

Is there something include in Xamarin for Scrolling the View with Keyboard when it Shows and Hides ?
Or should I have to do it on my own, like Obj-C.

Thx

submit bug to bugzilla

$
0
0

Hi folks.
This week I've submitted 4 bugs to bugzilla.
Every bug has a project attached to help Xamarin Team to reproduce and (I hope) solve the bug.
To reproduce the bug, write the test project, submit the bug ... I think to have spent some hours to help Xamarin and all of us to have a better product.
Could I have a discount for the next indie license I'll buy in next months, so the time I've spent is not "lost time"?

Alessandro

Hiding Keyboard when showing a calendar as a subview is not working when editing begin on text field

$
0
0

I have a date text field...Once it is highlighted I want to load a calendar..I am using the FMCalendar from Xamarin components.
I add the calendar as a subview...the calendar loads as soon as the date text field editing begin, and before loading it I am calling resign first responder on every text field in the view, I am even disabling editing on the whole view...and it still does not work...calendar shows and keyboard hides the lower half of it...its interesting to note that I have a previous text field for phoneNumber text box, if from there I hit next on the keyboard which would resign first responder and set the Date text field as the first responder than the keyboard gets hidden and calendar shows correctly...I would appreciate any help or insight on this, have been trying to figure it out for a while now...Thanks!!!

        this.PhoneNumber.ShouldReturn = delegate
        {
            this.PhoneNumber.ResignFirstResponder();
            this.Date.BecomeFirstResponder();
            return true;
        };

        this.Date.EditingDidBegin += (object sender, EventArgs e) =>
        {


            this.FirstName.ResignFirstResponder ();
            this.LastName.ResignFirstResponder ();
            this.EmailAddress.ResignFirstResponder ();
            this.PhoneNumber.ResignFirstResponder ();
            this.NumberGuest.ResignFirstResponder ();
            this.Date.ResignFirstResponder();
            this.Date.EndEditing(true);
            this.View.EndEditing(true);
            this.View.AddSubview (fmCalendar);


        };

Storing Sensitive User Security Data

$
0
0

Hi All,

I'm currently researching the best way to store sensitive data on the various mobile platforms. My web service implementation uses OAuth2 for security so the plan is to initially ask for a users credentials to obtain the tokens (access and refresh) and then I'm going to store these instead of the users actual username and password.

iOS

Obviously iOS has had the KeyChain forever so that platform is a no brainer on the approach.

Android

Since we are targeting Android 4.0+ (API level 14+) this platform also has a KeyChain so we are good to go here as well.

Windows Phone

Is there a similar approach on the WP platform?

I was initially thinking about using plain encryption but this would still require some input from the user or a static password embedded in the application that would complete defeat the entire exercise and it seems a little daft when there are device enabled approaches to leverage in order to properly hand off some of the security concerns to the hardware. The problem is I cannot identify if the WP platform has a similar feature that could be used.

Any info would be great.

TIA,

J

Viewing all 204402 articles
Browse latest View live




Latest Images