AsyncTask からサービスを開始しようとしましたが、開始していることを確認できません。
私のエラーが表示されることを願っています。
ここに私のコード:
protected String doInBackground(String... params) {
//starts service number activite
Intent i = new Intent(context, DownloadService.class);
i.putExtra("url", "www.google.com");
i.putExtra("receiver", new DownloadReceiver(new Handler()));
context.startService(i);
これが私のサービスです
public class DownloadService extends Service{
protected void onHandleIntent(Intent intent) {
String urlLink = intent.getStringExtra("url");
ResultReceiver receiver = intent.getParcelableExtra("receiver");
// some body
Bundle data = new Bundle();
//publishing progress
data.putString("key",getActivityUrl() );
receiver.send(1,data);
}
ResultReceiver resultReceiver;
public int onStart(Intent intent, int flags, int startId) {
onHandleIntent( intent)
return START_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
public String getActivityUrl() {.....}
そして私のマニフェストファイル:
<service android:name="connection.DownloadService">
<intent-filter>
<action android:name="connection.DownloadService">
</action>
</intent-filter>