【发布时间】:2014-02-14 09:40:10
【问题描述】:
我正在尝试让手机上的 Led 通知以特定顺序和不同颜色闪烁。
package com.example.led1;
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 android.graphics.Color;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
Notification notf = new NotificationCompat.Builder(this)
.setAutoCancel(false)
.setLights(0xffff00, 1000, 100)
.setLights(0xff0000, 5000, 100)
.setLights(0x0000FF, 10000, 100)
.build();
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(2, notf);
// new Timer().scheduleAtFixedRate(notf, 100,5000);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
} `
当应用程序在我的手机上运行时,它只会闪烁三个 setLights 命令的最后一种颜色。如何按顺序运行这三个 setLights 并添加一个 while 循环?
【问题讨论】:
标签: android notifications led