2013-07-31 3 views
0

지금 서비스를 실행해야합니다.이 활동을 수행하려면 길게 누르는 청취자가 다른 활동 또는 홈 스크린에서 좌표를 가져온 다음 좌표를 표시하는 활동을 시작해야합니다. 나는 어떻게해야합니까?서비스에서 활동을 시작하려면

답변

0

사용 의도는 새로운 활동을 시작하고 번들에 좌표의 값을 전달하거나 의도 엑스트라

MarcinGil

android.app.Service에 의해 게시 솔루션에서

0
Intent dialogIntent = new Intent(getBaseContext(), myActivity.class); 
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
getApplication().startActivity(dialogIntent); 

또는 은 후손하기 android.app.Context의 startActivity를 직접 사용할 수 있습니다. 그러나 모든 활동 외부에서이를 시작하기 때문에 FLAG_ACTIVITY_NEW_TASK 플래그를 인 텐트에 설정해야합니다. 예를 들어

:

Intent i = new Intent(); 
i.setClass(this, MyActivity.class); 
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(i);  
where this is your service. 
0

그냥 한 OnCreate에 다음 코드를 넣어() 서비스에

Intent intent = new Intent(Your_Context, Your_Class); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 
관련 문제