Bonjour Messieurs,

Je suis actuellement confronté a un problème dans le développement d'application android, le but de mon application est de parser un flux RSS et d'afficher les images contenue dans ce flux, j'aimerais comprendre le principe des HANDLER car même en lisant pas mal d'article pour moi ca reste flou.

Malheureusement mon image ne change pas ni aurait-il pas un moyen de changer l'image après un certain temps ?

Je n'arrive pas à trouvé l'algorithme. et je me demande comment faire. Ci dessous mon code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
public class DisplayImg extends Activity {
	private Handler mHandler;
	long start = 1;
	private int cmp = 0;
	private List<Long> idss = new ArrayList<Long>();
	private List<Integer> durations = new ArrayList<Integer>();
	private ArrayList<FeedForDisplay> feeds;
	private Bitmap bitmap;
	private int duration;
	private List<String> imageUris = new ArrayList<String>();
 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.listsetting);
		Intent thisIntent = getIntent();
 
		String url = thisIntent.getExtras().getString("url");
		mHandler = new Handler();
		feeds = ContainerDataDisplay.getFeeds(url);
		if (feeds != null) {
			for (FeedForDisplay feed : feeds) {
				// listIdfeed.add(feed.getId());
				// Log.i("ImageTitle", feed.getDescription());
				// Log.i("EnclosureImageURI", feed.getEnclosureImageURI());
				// DownloadImage(feed.getEnclosureImageURI(), feed.getId());
				duration = feed.getDuration();
				Log.i("id",String.valueOf( feed.getId()));
				imageUris.add(feed.getEnclosureImageURI());
 
			}
 
			mHandler.removeCallbacks(mUpdateTimeTask);
			mHandler.postDelayed(mUpdateTimeTask, 100);
		}
	}
 
 
 
	private Bitmap LoadImage(String URL) {
		Bitmap bitmap = null;
		InputStream in = null;
		try {
			in = OpenHttpConnection(URL);
			bitmap = BitmapFactory.decodeStream(in);
			in.close();
		} catch (IOException e1) {
		}
		return bitmap;
	}
 
	private InputStream OpenHttpConnection(String strURL) throws IOException {
		InputStream inputStream = null;
		URL url = new URL(strURL);
		URLConnection conn = url.openConnection();
 
		try {
			HttpURLConnection httpConn = (HttpURLConnection) conn;
			httpConn.setRequestMethod("GET");
			httpConn.connect();
 
			if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
				inputStream = httpConn.getInputStream();
			}
		} catch (Exception ex) {
		}
		return inputStream;
	}
 
	private Runnable mUpdateTimeTask = new Runnable() {
		public void run() {
 
 
 
			for (String ig : imageUris) {
				Log.i("test", ig.toString() );
				bitmap = LoadImage(ig);
 
				ImageView img = (ImageView) findViewById(R.id.img);
				img.setImageBitmap(bitmap);
			}
				mHandler.postDelayed(mUpdateTimeTask, duration * 1000);
 
		}
 
	};
}


Si quelqu'un à la gentillesse de m'éclairer un peu sur ce sujet, car il reste très flou pour moi.
Cordialement