마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

다른프로젝트의 서비스를 호출하고 싶은데 잘안되네요

0 추천
안녕하세요

다른프로젝트 서비스 호출을 하는 테스트를 하고 있는데 잘안되서 문의드립니다

sample1 과 sample2라는 앱 2개를 만들었습니다
1에서 2의 서비스를 바로 호출하고 싶은데 Unable to start service Intent 오류가 나오면서 잘안되네요..

 

sample2에 서비스 (windowmanager를 사용하고 있는 서비스 앱위에그리기 권한은 다 설정되있음)
 <service
        android:enabled="true"
        android:exported="true"
        android:name=".Sample2Service"
        android:process=":remote"
       >
        <intent-filter>
            <action android:name="com.example.sample2.Sample2Service" />
        </intent-filter>
    </service>
</application>

sample1에서는 it 1234,를 실행했는데 잘안됩니다
Intent it1 = new Intent();
ComponentName compName = new ComponentName("com.example.sample2","com.example.sample2.Sample2Service");
it1.setComponent(compName);//Unable to start service Intent

Intent it2 = new Intent();
it2.setAction("com.example.sample2.Sample2Service");
it2.setPackage("com.example.sample2"); //Unable to start service Intent

Intent it3 = new Intent("com.example.sample2.Sample2Service");// Service Intent must be explicit
it3.setPackage("com.example.sample2"); //Unable to start service Intent

Intent it4 = new Intent();// Service Intent must be explicit
it4.setClassName("com.example.sample2","com.example.sample2.Sample2Service"); //Unable to start service Intent
startService(it4);

 

sample2내에서는 서비스 호출이 잘됩니다만
1에서의 매니페스트 옵션은 true,false 나 remote 옵션을 뺏다 넣다 해봤는데
1에서 호출하는경우 unable to start service intent 오류가 나옵니다
참고로 1에서 2의 activity를 호출하면 잘됩니다만 서비스 호출은 잘안되네요..
생초 (1,110 포인트) 님이 2021년 4월 30일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...