Bonjour

Je cherche actuellement à réaliser une application me permettant d’allumer et d'éteindre la led de notification (de mon nexus 4) quand je le souhaite. Malheureusement quand je tente de le faire rien ne se passe. Pourriez-vous me dire ce qui ne va pas dans mon code, svp ?

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
 
public class MainActivity extends Activity {
 
	private static final int IdNotification = 1;
	Notification notification = new Notification();
	NotificationManager mNM;
 
	public void TurnLedOn()
	{
	notification.ledARGB = Color.BLUE;
	notification.ledOffMS = 0;
	notification.ledOnMS = 1;
	notification.flags |= Notification.FLAG_SHOW_LIGHTS;
	}
 
	public void TurnLedOff()
	{
		notification.ledOffMS = 1;
		notification.ledOnMS = 0;
	}
 
 
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
 
 
		mNM=NotificationManager)getSystemService(NOTIFICATION_SERVICE);
		mNM.notify(IdNotification, notification);
		TurnLedOn();
 
		//pour attendre un peu avant d'eteindre ma led
		int j;
		for(int i=0;i<1000000;i++){
			j=i*i;
		}
 
 
		TurnLedOff();
		mNM.cancel( IdNotification );
	}
Merci d'avance pour vos réponses.