I am trying to make the notification Led blink in a certain way and when i run the app from Eclipse with my phone connected it works as expected, but when i run it directly from my phone it doesn't work as it should (showing the colors not respecting the order or the while loop). I also have a problem with the main page of the app, it is always black and doesn't show anything on it (like the button i just added) . Now after i added the button i get many markers at the "void onActionPerformed(ActionEvent e1 ){" line :"Action event cannot beresolved to a type", "syntax error on token "(" and ")" expected" and "void is an invalid type for the variable OnActionPerfermed"
How can i fix this errors ?
package com.example.led;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.view.Menu;
import java.awt.event.ActionEvent;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
boolean isClicked = false;
void actionPerformed (java.awt.event.ActionEvent e1){
if(!isClicked){
isClicked = true;
int i=0;
while (i==0){
Notification notf = new NotificationCompat.Builder(this)
.setAutoCancel(false)
.setLights(0x0000FF, 5000, 100)
.build();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(2, notf);
try { Thread.sleep(3000); }
catch (InterruptedException e) { e.printStackTrace(); }
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(2);
Notification notg = new NotificationCompat.Builder(this)
.setAutoCancel(false)
.setLights(0xffff00, 5000, 100)
.build();
NotificationManager nNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nNotificationManager.notify(3, notg);
try { Thread.sleep(3000); }
catch (InterruptedException e) { e.printStackTrace();}
NotificationManager notification1Manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notification1Manager.cancel(3);
Notification noth = new NotificationCompat.Builder(this)
.setAutoCancel(false)
.setLights(0xff0000, 5000, 100)
.build();
NotificationManager hNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
hNotificationManager.notify(4, noth);
try { Thread.sleep(3000); }
catch (InterruptedException e) { e.printStackTrace(); }
NotificationManager notification2Manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notification2Manager.cancel(4);
}
}
else
{
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(2);
NotificationManager notification1Manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notification1Manager.cancel(3);
NotificationManager notification2Manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notification2Manager.cancel(4);
}
}}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}