android - Accessing Method from Interface Throwing Conversion Error -
public class newcallinfo { public string site { get; set; } public string customername { get; set; } public string customerphone { get; set; } public string customerext { get; set; } public string customeraddress { get; set; } public string customercity { get; set; } public string customerstate { get; set; } public string customerzip { get; set; } public string servicetype { get; set; } public string priority { get; set; } public string description { get; set; } public string technician { get; set; } public string serial { get; set; } public string model { get; set; } } public interface inewcall { newcallinfo getnewcallinfo(string site); } public class handlenewcall : inewcall { private sqlitehelper helper {get;set;} public handlenewcall(context context) { helper = new sqlitehelper(context); } public newcallinfo getnewcallinfo(string site) { string whereclause = string.format("where site='{0}'", site); icursor callcursor = _helper.readabledatabase.query("newcall", null, whereclause, null, null, null, null); newcallinfo newcall = new newcallinfo(); while(callcursor.movetonext()) { newcall.site = callcursor.getstring(0); newcall.customername = callcursor.getstring(1); newcall.customerphone = callcursor.getstring(2); newcall.customerext = callcursor.getstring(3); newcall.customeraddress = callcursor.getstring(4); newcall.customercity = callcursor.getstring(5); newcall.customerstate = callcursor.getstring(6); newcall.customerzip = callcursor.getstring(7); newcall.servicetype = callcursor.getstring(8); newcall.priority = callcursor.getstring(9); newcall.description = callcursor.getstring(10); newcall.technician = callcursor.getstring(11); newcall.serial = callcursor.getstring(12); newcall.model = callcursor.getstring(13); } if (string.isnullorempty(newcall.site)) newcall.site = "none"; return newcall; } } class myapp : application { public inewcall newcall { get; set; } public myapp(intptr handle, jnihandleownership transfer) :base(handle, transfer) { } public override void oncreate() { newcall = new handlenewcall(this); } }
then in activity when do:
var call = ((myapp) application).newcall.getnewcallinfo("sitestring");
i "cannot cast source type destination type". of above stuff interfaces , application sub classes extremely new me, feel i've done same way examples online. namely in this example. been banging head against wall hours. see glaring i'm missing?
you're missing [application]
attribute on myapp
class generate androidmanifest.xml, android doesn't know use application class. because of that, trying cast application
property myapp
failing since object isn't instance of class. update class definition like:
[application] public class myapp : application { // ... }
Comments
Post a Comment