Bonjour a tous,

Je découvre actuellement les parcelable et je rencontre un soucis. Mon application recoit des coordonnees GPS par le biais d'un service, afin de les afficher sur un fragment j'ai cru comprendre qu'il fallait les parceller. Ce que j'ai fais, seulement je n'arrive pas a les afficher.
Pouvez vous m'aider ?
Ma classe qui implémente parcelable
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
public class PositionGps implements Serializable, Parcelable{
    //public static final long serialVersionUID = 0xBADA55;
    private double latitude;
    private double longitude;
 
    public PositionGps(){
    }
    private void writeObject(ObjectOutputStream out){
        try {
            out.writeDouble(this.getLatitude());
            out.writeDouble(this.getLongitude());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    private void readObject(ObjectInputStream in){
        try {
            this.setLatitude(in.readDouble());
            this.setLongitude(in.readDouble());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    public double getLatitude(){
        return this.latitude;
    }
    public void setLatitude(double latitude){
        this.latitude = latitude;
    }
 
    public double getLongitude(){
        return longitude;
    }
    public void setLongitude(double longi){
        this.longitude = longi;
    }
 
    @Override
    public int describeContents() {
        return 0;
    }
 
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeDouble(this.getLatitude());
        dest.writeDouble(this.getLongitude());
    }
    public static final Parcelable.Creator<PositionGps> CREATOR = new Parcelable.Creator<PositionGps>() {
        @Override
        public PositionGps createFromParcel(Parcel source) {
            return new PositionGps(source);
        }
 
        @Override
        public PositionGps[] newArray(int size) {
            return new PositionGps[size];
        }
    };
 
    public PositionGps(Parcel in) {
        latitude = in.readDouble();
        longitude = in.readDouble();
    }
}

Mon service qui récupère les données
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
public class serviceReception extends Service {
    private static final int SERVERPORT = 4000;
    PositionGps pos ;
    private Intent i;
    //private HashMap<String,double> params;
    public serviceReception() {
    }
 
    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }
 
    @Override
    public void onCreate(){
        pos = new PositionGps();
 
        i = new Intent();
        connexion c = new connexion();
        c.execute();
    }
    public class connexion extends AsyncTask<Void,Void,String> {
        @Override
        protected String doInBackground(Void... params) {
            Socket client =  new Socket();
            ServerSocket server = null;
            ObjectInputStream in1;
            try{
                server = new ServerSocket(SERVERPORT);
            }catch(Exception e){
 
            }
            try {
                while(true){
                    Log.i("Server Started...", "ok0");
                    client = server.accept();
                    Log.i("Server Started...","ok");
                    in1= new ObjectInputStream(client.getInputStream());
                    Bundle b = new Bundle();
                    try{
                        try {
                            pos = (PositionGps)in1.readObject();
                            if(pos != null){
                                b.putParcelable("params",pos);
                                Log.i("lat",""+pos.getLatitude());
                                Log.i("lon",""+pos.getLongitude());
 
                            }
                        } catch (ClassNotFoundException e) {
                            e.printStackTrace();
                        }
                    }catch(StreamCorruptedException e){
                        System.out.println(e);
                    }
                    //pos = null;
 
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            finally{
                try {
                    client.close();
                    server.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
 
            }
            return null;
        }
 
        protected void onPostExecute(String result){
        }
    }
}
Mon fragment sur lequel je veux afficher les données
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
public class Fragment_reception extends Fragment {
    private View rootView;
    private TextView tvLat, tvLong;
    private static final int SERVERPORT = 4000;
    private Intent i;
    private Bundle b;
    PositionGps pos ;
    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_reception, container, false);
        tvLat = (TextView)rootView.findViewById(R.id.tv_Latitude);
        tvLong = (TextView)rootView.findViewById(R.id.tv_Longitude);
 
        //pos = getActivity().getIntent().getParcelableExtra("params");
 
        b= getActivity().getIntent().getExtras();
        if(b != null){
            pos = b.getParcelable("params");
            tvLat.setText(""+pos.getLatitude());
            tvLong.setText(""+pos.getLongitude());
        }
        else{
            Log.i("ta","ta martino");
            Toast.makeText(rootView.getContext(),"Pas de pos",Toast.LENGTH_LONG);
        }
 
 
 
        return rootView;
    }
}
Merci