을 단순히 호출 클래스 사이의 의사 소통으로 인터페이스의 도움을 활동. 예
interface Communicator{
void startCall();
}
Public class Example{
public void someMethodToBeCalled(){
Communicator communicator = new MainActivity();
communicator.startCall();
}
}
class MainActivity extends AppCompactActivity implements Communicator{
void startCall() {
Intent callIntent= new Intent
(Intent.ACTION_CALL,Uri.parse("tel:"+"0554515514"));
context.startActivity(callIntent);
}
}
커뮤니케이터 클래스의 인스턴스를하는 동안, 당신이해야 할 것을 관찰
,
Communicator communicator = new MainActivity();
당신이 startCall() 활동에 communicator.startCall을 (구현하는 바와 같이) MainActivity의 트리거 startCall 메소드.
작동하지 않는다는 의미입니까? 컨텍스트를 통과 시켰습니까? – ABDevelopers
잘 작동하는 코드를 표시 할 수 있습니까? – NonCreature0714
컨텍스트를 @Nadav – Jorgesys