Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging LED color for notifications
    primarykey
    data
    text
    <p>I am basically just experimenting with Android development, and a couple of days ago I came across this app called "<a href="https://market.android.com/details?id=com.jb.gosms" rel="noreferrer">Go SMS Pro</a>", which, among other things, can set up notifications in different colors (blue, green, orange, pink and light blue). So, I have tried to do this myself in my own app, however I cannot change neiher the color nor the blinking internal of the LED. I currently use this code:</p> <pre><code>public class MainActivity extends Activity { static final int NOTIFICATION_ID = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(buttonOnClick); } public OnClickListener buttonOnClick = new OnClickListener() { @Override public void onClick(View v) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); Notification notification = new Notification(R.drawable.icon, "Hello", System.currentTimeMillis()); notification.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL; notification.ledARGB = Color.BLUE; notification.ledOnMS = 1000; notification.ledOffMS = 300; Context context = getApplicationContext(); CharSequence contentTitle = "My notification"; CharSequence contentText = "Hello World!"; Intent notificationIntent = new Intent(MainActivity.this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(NOTIFICATION_ID, notification); } }; } </code></pre> <p>But as I said, it doesn't work the way I want it to; instead it just blinks in regular green with the default delay, and not the one I have set in my code.</p> <p>Can anyone see what is wrong with my code, or know if I have to do something else to achieve this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload