基本的なJavaに精通している場合は、コールバックメカニズムを実行する必要があります。ここでは、Javaでのコールバックの概要を説明しようとしています...
//Here is you class B :
class ClassB {
interface ILocationListerner {
void setLocations(float lat, float long);
}
ILocationListerner mLocationListener = null;
/// Here is your static method that set Listerner and call by Activity A
public void static setLocationListerner(ILocationListerner listener){
this.mLocationListener = listener;
}
//Gel loaction method.
public static void getLocation(){
////
...
////
mLocationListener.setLocation(lat,lng);
}
}// ClassB ends here
/// Activity A
class ActivityA extends Activity {
onCreate(){
ClassB.setLocationListerner(new ILocationListerner {
@Override
void setLocations(float lat, float long){
/// do your stuff and call finish();
}
} );
ClassB.getLocation();
}
}
}
あなたがこれを理解することを願っています...