Bonsoir,
je cherche comment passer de paramètre d'une activity vers un service j'au essayé ce code mais ça ne marche pas:

***Côté Activty***
Code JAVA : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
Intent myIntent = new Intent(ContactActivity.this, NotifMe.class);
			myIntent.putExtra("name", "je suis une notifcation");
			PendingIntent pendingIntent = PendingIntent.getService(ContactActivity.this, 0, myIntent, 0);
			AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
			Calendar calendar = Calendar.getInstance();
 
			calendar.setTimeInMillis(System.currentTimeMillis());
 
			calendar.add(Calendar.SECOND, 10);
 
			alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
***Côté Service***
Code JAVA : 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
 
@Override
	public void onStart(Intent intent, int startId) {
		// TODO Auto-generated method stub
		super.onStart(intent, startId);
		if(intent.hasExtra("name")){
			msg=intent.getStringExtra("name");
		}
 
	}
 
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		// TODO Auto-generated method stub
		msg=intent.getStringExtra("name");
		return super.onStartCommand(intent, flags, startId);
 
	}