アプリのIntentServiceを使用して、アプリケーションアクティビティを妨害したり妨害したりせずに、バックグラウンドスレッドでサーバーからデータを取得したいと考えています。これが私の単純なIntentServiceです
public class SearchService extends IntentService {
public SearchService() {
super("SearchService");
}
@Override
protected void onHandleIntent(Intent intent) {
Log.d("Tag","service started");
}
}
アプリケーションのメインアクティビティでこのサービスを開始します
public class ChannelsActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this , SearchService.class);
startService(intent);
}
マニフェストファイルでサービス属性も定義していますが、機能しません。何が問題なのかわかりません。
<application
<activity
android:name=".ChannelsActivity"
android:screenOrientation="landscape"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".SearchService"/>
</application>
私はこの問題で立ち往生しています。どんな助けでも私にとって本当に役に立ちます。