インテント ダウンロード サービスを作成しました。ダウンロード データを Toast とメイン アクティビティの Text に渡したいと考えています。ダウンロード サービスは、アラーム マネージャから繰り返し起動する必要があります。どうすればいいですか?
現在、Toast には表示されませんが、ネットワーク トラフィックがあります。データはダウンロードされますが、表示されません。
関連コード:
public class DownloadService extends IntentService {
public String response;
public DownloadService() {
super("DownloadService");
}
// Will be called asynchronously be Android
@Override
protected void onHandleIntent(Intent intent) {
//String urldown = intent.getStringExtra("url");
String urldown="http://......";
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(urldown);
try {
HttpResponse execute = client.execute(httpGet);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
while ((s = buffer.readLine()) != null) {
response += s;
}
} catch (IOException e) {
e.printStackTrace();
}
Intent intentsend=new Intent("update");
intentsend.putExtra( "downdata",response);
sendBroadcast(intentsend);
}