2016-05-27 2 views
2

Hallo Ich habe eine Android-App, die sowohl in Xamrian Native und Xamrian Formen geschrieben wird Ich versuche, die App zu öffnen eine Seite, die ich getan habe xamrian bildet sich, wenn der Benutzer auf eine Schaltfläche klicken in diesem Fall Schaltfläche_1 ist jedoch, wenn ich diese auf einem Gerät laufen und sagte klicken erhalte ich einen Absturz von diesem Fehler folgende:System.ArgumentException: type Parametername: Typ ist nicht abgeleitet von einem Java-Typ

System.ArgumentException: type Parameter name: Type is not derived from a java type. 

hier ist mein Code für die Seite, die die Schaltfläche hat auf ihm:

using Android.App; 
using Android.Content; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 
using Xamarin.Forms.Platform.Android; 

namespace ReadyMo.Droid 
{ 
    [Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivityHomeView : FormsApplicationActivity 
    { 

     Button button; 


     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 

      // Set our view from the "main" layout resource 
      SetContentView(Resource.Layout.Main); 




      //This is the button im having issues with!!!!!! 

      //Code That opens the Settings Activity 

      button = FindViewById<Button>(ReadyMo.Droid.Resource.Id.button_1); 

      button.Click += (sender, e) => { 
       // this is our Xamarin.Forms screen 
       StartActivity(typeof(SettingsView)); 
      }; 




     } 




    //Code That Opens The Tips Activity! 

    [Java.Interop.Export("Tips")] // The value found in android:onClick attribute. 
     public void btnOneClick1(View v) // Does not need to match value in above attribute. 
     { 
      StartActivity(typeof(Tips)); 
     } 

     //Code That Opens The Contact Activity! 

     [Java.Interop.Export("contact")] // The value found in android:onClick attribute. 
     public void btnOneClick2(View v) // Does not need to match value in above attribute. 
     { 
      StartActivity(typeof(Contact)); 
     } 


     //Code That Opens The Modot Activity! 

     [Java.Interop.Export("modot")] // The value found in android:onClick attribute. 
     public void btnOneClick3(View v) // Does not need to match value in above attribute. 
     { 
      StartActivity(typeof(Modot)); 
     } 


     //Code That Opens The Weather Activity! 

     [Java.Interop.Export("wether")] // The value found in android:onClick attribute. 
     public void btnOneClick4(View v) // Does not need to match value in above attribute. 
     { 
      StartActivity(typeof(Weather)); 
     } 



     //Code That sends a email to [email protected] 

     [Java.Interop.Export("email")] // The value found in android:onClick attribute. 
     public void btnOneClick5(View v) // Does not need to match value in above attribute. 
     { 
      var email = new Intent(Android.Content.Intent.ActionSend); 
      email.PutExtra(Android.Content.Intent.ExtraEmail, new string[] { "[email protected]" }); 
      email.PutExtra(Android.Content.Intent.ExtraSubject, "SEMA"); 
      email.PutExtra(Android.Content.Intent.ExtraText, "Sent Using The ReadyMO App"); 
      email.SetType("message/rfc822"); 
      StartActivity(email); 
     } 


     //Code That Opens Calls The State Emergency Management Agency ! 

     [Java.Interop.Export("call")] // The value found in android:onClick attribute. 
     public void btnOneClick6(View v) // Does not need to match value in above attribute. 
     { 

      var uri = Android.Net.Uri.Parse("tel:5735269100"); 
       var intent = new Intent(Intent.ActionDial, uri); 
       StartActivity(intent); 
      } 

     //Code That Opens The Fax Activity! 

     [Java.Interop.Export("fax")] // The value found in android:onClick attribute. 
     public void btnOneClick7(View v) // Does not need to match value in above attribute. 
     { 
      StartActivity(typeof(Fax)); 
     } 




    } 
    } 

Jede Hilfe wäre erstaunlich!

Vielen Dank im Voraus! :)

+0

Versuchen Sie, TypeToken zu verwenden) in nativen verwende ich wie "new TypeToken () {}. GetType()" –

+0

Stepan Maksymov danke für die Antwort können Sie bitte ein wenig konkreter sein? :) – Phoneswapshop

+0

@StepanMaksymov Ich habe das gleiche Problem auf Xamarin.android beim Versuch, einen Dienst zu starten, können Sie bitte Ihren Kommentar in eine Antwort erarbeiten –

Antwort

0

, was das Problem ist, am Ende war die FormsApplicationActivity i geändert:

[Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivityHomeView : FormsApplicationActivity 
    { 

zu:

[Activity(Label = "ReadyMO", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivityHomeView : Activity 
    { 

und jetzt ist es nicht abstürzen!

Verwandte Themen