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;
    }

}

java.awt.event.ActionEvent in Android since when?

I just followed an online tutorial, I'm a beginner in android code. What should i change to make it work ?

I've managed to use something like onClickListener . When i use it now i have to press the Button, turn the screen off manualy and admire the notification but when i turn thescreen back on the app becomes unresponsive.
Why does the program crash ?

package com.example.led;


//import java.awt.Button;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
//import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.view.Menu;
import android.view.View;
//import android.view.View.OnClickListener;




    public class MainActivity extends Activity {

    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


        public void ButtonOnClick(View v) {
            switch (v.getId()) {
              case R.id.button1:
                  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);
                  }





                break;

              }
        }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

You need to replace void actionPerformed (java.awt.event.ActionEvent e1) with some other listener method like onClick where you trigger it by button and button has to be part of application

I replaced

void actionPerformed (java.awt.event.ActionEvent e1)

as you can see in the code posted above. Now i have a problem that the app crashes when i turn the screen back on using the above code. How can i fix that ?

How would I know if you did not post any error log messages?

[2014-02-16 15:48:54 - Led] R.java was modified manually! Reverting to generated version!

 <Button
        android:id="@+id/button1"
        android:onClick="ButtonOnClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="110dp"
        android:text="Button" />

I get a warning at the last line : [I18N] Hardcoded string "Button", should use @string resource

Where should I look for other errors in the program ?

I also noticed that if i remove the try/catch commands the lights turn on/off very very fast not respecting the .setLights(0xffff00,5000, 3000) times. It only uses the color but not the times (ms)

LOL have to laugh on first one. Obviously you are on Eclipse that does give this crap (wouldn't happen with IntelliJ or AndroidStudio). Nevertheless message is specific you have hardcoded text android:text="Button" so you should extract it to strings.xml

As for runtime error Eclipse must have logcat somewhere. Which is what you need to find.

And do not remove try/catch. You could always create run method where you place try/catch and call it each time you make change to Notifications

This is my logcat . Can you help me with the errors ?

Please delete logcat before or application start up and then make it it crash. Once that achieved post new logcat. (Sorry but I'm not willing to search your logs for error reports as it will include addition stuff like facebook putting stuff in error logs that is irrelevant)

This is the shortest log i could make including the error. Thanks again.

I do not see any crash reports there. You sure you captured it?
If it is gone easier for you you can always share link to your github project if you using github or just upload zip of your project and I can have look that way.

Project RAR

It has 1.4 MB and i can't upload it here. If you have problems downloading tell me and i will find another site.

The strangest thing happened . I installed the sdk on another computer, i imported the old project and now when i plug in the phone, the app runs completly different. What could have happened ?