Bonjour

Je suis nouveau dans le developpement android . J'ai une activity MonEspace qui contient une autre class "ListAllFiles"
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
class ListAllFiles extends AsyncTask<Object, Object, Object> {
 
		protected void onPostExecute(Object result) {
			// TODO Auto-generated method stub
			super.onPostExecute(result);
 
			mListView.setEnabled(true);
			mProgress.setVisibility(View.GONE);
			removeDialog(0);
			Log.i("MonEspace", "doInBack============End");
		}
 
		@Override
		protected Object doInBackground(Object... params) {
			// TODO Auto-generated method stub
 
			Log.i("MonEspace", "doInBack============Start");
 
			runOnUiThread(new Runnable() {
 
 
				public void run() {
					// TODO Auto-generated method stub
 
					if (isOnline()) {
						String textList = null;
						MultiStatus ms = null;
 
						try {
							ms = listAll(url, httpClient);
							String[] name = url.split("webdav.php/");
 
							mCurrentDir.setText(" Cloud/"+URLDecoder.decode(name[1]));
 
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							mCurrentDir.setText(" Cloud/");
						}
						// if (ms.equals(null)) {
						if (ms == null) {
							// Toast.makeText(getApplicationContext(),
							// "There is some problem in listing files",
							// 1).show();
						} else {
							listUrl = new String[ms.getResponses().length - 1];
 
							listName = new String[ms.getResponses().length - 1];
							Log.e("length",
									String.valueOf(ms.getResponses().length));
							if (ms.getResponses().length == 1) {
								mTextFlag=false;
								Toast.makeText(
										getApplicationContext(),
										"Le dossier est vide.Cliquer sur le bouton retour",
										1).show();
 
								mNoText.setVisibility(View.INVISIBLE);
							} else {
								mTextFlag=false;
								//mNoText.setVisibility(View.GONE);
								for (int i = 1; i <= ms.getResponses().length - 1; i++) {
									String respString = ms.getResponses()[i]
											.getHref();
									Log.v(TAG,"Response"+respString);
									listUrl[i - 1] = ms.getResponses()[i]
											.getHref();
									File file = new File(URLDecoder.decode(ms
											.getResponses()[i].getHref()));
									mListFile.add(file.getName());
									Log.i("ListFile", String.valueOf(i) + "  "
											+ file.getName());
 
									String fileName = new StringBuffer(
											listUrl[i - 1]).reverse()
											.toString();
									String[] fileNameArray = fileName
											.split("/");
									if ((fileName.substring(0, 1)).equals("/")) {
										// fileName = fileName.substring(1);
										listName[i - 1] = new StringBuffer(
												fileNameArray[1] + "/")
												.reverse().toString();
 
 
 
 
									} else {
 
										listName[i - 1] = new StringBuffer(
												fileNameArray[0]).reverse()
												.toString();
									}
									if (textList == null) {
										textList = listName[i - 1] + "\n";
									} else {
										textList = textList + listName[i - 1]
												+ "\n";
									}
 
									Log.d("response", respString);
								}
							}
 
							adapter.setData(listName);
							mListView.setAdapter(adapter);
						}
 
					} else {
						WebNetworkAlert();
					}
				}
			});
			return null;
		}
 
	}
Maintenant je veux appeler cette classe dans une nouvelle activity Favoris plus précisement dans le code ou le actionId==ID_OPE
ceci le code de la classe Favoris:
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package com.example.cloud;
 
import java.io.File;
import java.net.URLDecoder;
import java.util.List;
 
import org.apache.jackrabbit.webdav.ordering.Position;
 
import com.example.cloud.MonEspace.ListAllFiles;
 
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.Toast;
public class Favoris extends Activity{
	 int NOTFICATION_ID = 198990;
	static Notification notification;
 
 
	private FavorisDataSource datasource;
	 public ListView list1=null;
	public int scrollpos=0;
	 private static final int ID_DEL = 2;
	 private static final int ID_OPE = 3;
	 private static final int ID_DOWN = 1;
	private static final String TAG = null;
	String fileName;
 
	String mFileUrl = "";
 
public  boolean isDownload=false;
static NotificationManager notificationManager = null;
 String titleText;
String notiText;
protected AsyncTask<Object, Object, Object>Laf;
private ListAllFiles LAF;
 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_favoris);
 
	    list1 =(ListView) findViewById(R.id.listView1);
 
	    datasource = new FavorisDataSource(this);
	    datasource.open();
 
	    List<Fav> values = datasource.getAllFavoris();
	    final Object[] table = values.toArray();
if (table.length==0){Toast.makeText(
		getApplicationContext(),
		"La liste des favoris est vide!Cliquer sur le bouton retour",
		1).show();}else{
	    // Use the SimpleCursorAdapter to show the
	    // elements in a ListView
	    ArrayAdapter<Fav> adapter = new ArrayAdapter<Fav>(this,
	            android.R.layout.simple_list_item_1, values);
	    list1.setAdapter(adapter);
 
  adapter.notifyDataSetChanged();
		}
    final ActionItem downItem = new ActionItem(ID_DOWN, "Telécharger",
			getResources().getDrawable(R.drawable.icon_telecharger));
 
	final ActionItem delItem = new ActionItem(ID_DEL, "Supprimer",
			getResources().getDrawable(R.drawable.icon_supprimer));
 
 
	final ActionItem opeItem = new ActionItem(ID_OPE, "Ouvrir", getResources()
			 .getDrawable(R.drawable.icon_ouvrir));
 
 
	final QuickAction mQuickAction = new QuickAction(this);
	final QuickActionFolder mQuickActionFolder = new QuickActionFolder(this);
	mQuickAction.addActionItem(downItem);
	mQuickAction.addActionItem(delItem);
    mQuickActionFolder.addActionItem(opeItem);
 
    mQuickActionFolder.addActionItem(delItem);
 
	list1.setOnItemClickListener(new OnItemClickListener() {
 
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				scrollpos=position;
				if (!((table[position].toString().substring(table[position].toString()
						.length() - 1)).equals("/"))) {
 
					mQuickAction.show(view);
 
				} 
 
 
				else  if (((table[position].toString().substring(table[position].toString()
						.length() - 1)).equals("/"))){
 
					mQuickActionFolder.show(view);}
 
 
			}
		});
 
	mQuickActionFolder.setOnActionItemClickListener(new QuickActionFolder.OnActionItemClickListener() {
 
 
 
 
 
 
 
		public void onItemClick(QuickActionFolder quickActionFolder, int position,
				int actionId) {
			Fav favoris = null;
			ArrayAdapter<Fav> adapter = (ArrayAdapter<Fav>)list1.getAdapter();
			ActionItem actionItem = quickActionFolder.getActionItem(position);
			if (actionId == ID_DEL) {
				if (list1.getAdapter().getCount() > 0) {
			        favoris = (Fav) list1.getAdapter().getItem(scrollpos);
			        datasource.deleteFavoris(favoris);
			        adapter.remove(favoris);}
				else if (actionId==ID_OPE){
 
 
				}
 
			}
		}
 
		public LayoutInflater getSystemService(String layoutInflaterService) {
 
			return null;
		}
		});
	mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
 
		public void onItemClick(QuickAction quickAction, int pos, int actionId) {
			Fav favoris = null;
			ArrayAdapter<Fav> adapter = (ArrayAdapter<Fav>)list1.getAdapter();
			ActionItem actionItem = quickAction.getActionItem(pos);
			if (actionId == ID_DEL) {
				if (list1.getAdapter().getCount() > 0) {
			        favoris = (Fav) list1.getAdapter().getItem(scrollpos);
			        datasource.deleteFavoris(favoris);
			        adapter.remove(favoris);}
 
		};
 
				}
 
		});
 
 
 
	mQuickAction.setOnDismissListener(new PopupWindow.OnDismissListener() {
		public void onDismiss() {
 
			// mMoreIv.setImageResource(R.drawable.ic_list_more);}
 
 
 
 
				}
			});
	}
 
 
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.terminer:
			finish();
 
		case R.id.parametres:
		{
 
		}
 
		}
		return true; 
		}
	protected void onResume() {
	    datasource.open();
	    super.onResume();
	  }
 
 
	  protected void onPause() {
	    datasource.close();
	    super.onPause();
	  }
 
 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.favoris, menu);
		return true;
	}
 
		}