Hello,
I'm currently learning Android development from online videos, the videos im watching show all the code example in one file i.e the .java so it doesn't confuse the user when trying to learn, my question is in regards to class that have methods inside them i.e connection to mysql, connecting to a WCF service etc
From what i've done so far I created a .java class inside
Appname > Src > com.example.appname called connectToWcf.java
Below is the class
[HIGH]
package com.example.newapplication;
public class connectToWcf {
public connectToWcf() {
// TODO Auto-generated constructor stub
}
public boolean connectToWcf(String name, boolean showAge, String postCode) {
return true;
}
}
[/HIGH]So one constructor, and one method which returns a type of boolean called connecToWcf
In my other classes which have activity's (pages) assigned to them i can then call the above from any other .java class as follows
[HIGH]
public void onClick(View v) {
connectToWcf Method = new connectToWcf();
boolean Success = Method.connectToWcf("Hello", true, "po156rt");
if(Success)
{
//Webmethod Great
}
else
{
}
}
[/HIGH]The question i have to ask is the above the correct way i should go about setting up global methods within my android application ?
As always thank you for your time.
I'm currently learning Android development from online videos, the videos im watching show all the code example in one file i.e the .java so it doesn't confuse the user when trying to learn, my question is in regards to class that have methods inside them i.e connection to mysql, connecting to a WCF service etc
From what i've done so far I created a .java class inside
Appname > Src > com.example.appname called connectToWcf.java
Below is the class
[HIGH]
package com.example.newapplication;
public class connectToWcf {
public connectToWcf() {
// TODO Auto-generated constructor stub
}
public boolean connectToWcf(String name, boolean showAge, String postCode) {
return true;
}
}
[/HIGH]So one constructor, and one method which returns a type of boolean called connecToWcf
In my other classes which have activity's (pages) assigned to them i can then call the above from any other .java class as follows
[HIGH]
public void onClick(View v) {
connectToWcf Method = new connectToWcf();
boolean Success = Method.connectToWcf("Hello", true, "po156rt");
if(Success)
{
//Webmethod Great
}
else
{
}
}
[/HIGH]The question i have to ask is the above the correct way i should go about setting up global methods within my android application ?
As always thank you for your time.