2016-10-25 2 views
0

Android 서비스로 구현 된 외부 프로젝트를 사용하고 싶습니다. 이 서비스는 매니페스트에 추가하여 사용됩니다다른 프로젝트에서 Android 서비스를 사용하는 방법은 무엇입니까?

<service android:name="com.my.ext.service"/> 

하지만 addthis 라인, 나는 오류 얻을 때 :

<com.my.ext.service 
    android:id="@+id/myview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 
:

Unresolved class 'TimerService' less... (⌘F1) 
Validates resource references inside Android XML files. 

을 그리고 난 내 프로젝트에 레이아웃을 추가 할 때

나는 오류를 얻을

the class could not be found 

외부 서비스를 Android Studio에 추가 프로젝트로 가져 왔습니다. 다른 프로젝트를이 프로젝트의 서비스로 사용하려면 어떻게해야합니까?

답변

0

서비스 클래스를 XML 레이아웃으로 사용할 수 없습니다. 당신은

<service android:name="com.my.ext.service"/> 

를 사용하여 해당 서비스를 사용하고 사용하여 응용 프로그램의 주요 활동에서 해당 서비스를 실행할 수 있습니다

private Intent OtherService; 
OtherService = new Intent((Context)this, (Class)YOURSERVICE.class); 
MainActivity.this.startService(MainActivity.this.OtherService); 
관련 문제