I wish to return a double from another class depending on input doubles. Any good links/examples to very simple project structure examples would be appreciated. Am I missing something in manifest. ie. activity 1
import com.example.app.utils.getRhumbLineBearingUtil;
double tbearing = getRhumbLineBearing(alata,alona,alatb,alonb);
double recipbearing=getRhumbLineBearing(alatb, alonb, alata, alona);
Activity 2 import com.example.app.utils.getRhumbLineBearingUtil;
double lattocbearing = getRhumbLineBearing(lat,lon,alatc,alonc);
double bcbearing=getRhumbLineBearing(alatb, alonb, alatc, alonc);
(I do this over many activities with 15 different returns with some inputs ie gps points changing rapidly)
Class package com.example.app.utils;
public class getRhumbLineBearingUtil
{
public double getRhumbLineBearing(double $lat1, double $lon1, double $lat2, double $lon2)
{Yada=trueRhumb ;
double Bearing=yada;
Return (bearing);
}
}
I am not interested in bearingTo which is the initial bearing hearing.
You should first learn a bit of Java programming and then move-up to android. You cannot do that that way. Try this:
And then in another class, after import and whatever you wanna use that method for, just call it like this:
Some notes here: static methods can be accessed via ClassName.methodName
This was what i understood from the question. Now if you want to exchange data between activities, then that is another story, you can use intents.
Some notes tho:
$variable
in Java, everything is passed by valueGetRhumbLineBearingUtil
you need to make that variables static as well.If what you mean is how to exchange data between two activities and you would like to pass some double values, you should use the method
putExtra(String name, double value)
orputExtra(String name, double[] value)
and get them from the second activityonCreate(Bundle savedInstanceState)
method.Otherwise use a static method that contains your method code.