我正在 Android 中做一个项目。我可以成功接收推送通知。
收到推送通知后如何开灯?
而且我还需要在收到推送通知时让我的手机振动。
最佳答案
有关更多信息,请参阅此 Link .
为您的 list 文件添加权限
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
编辑
// 1. Get a reference to the NotificationManager
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
// 2. Instantiate the Notification
int icon = R.drawable.notification_icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
// 3. Define the Notification's expanded message and Intent
Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
// 4. Pass the Notification to the NotificationManager
private static final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);
// ----------------------
// Add Sound
// ----------------------
// a. Default sound
notification.defaults |= Notification.DEFAULT_SOUND;
// b. Custom sound from SD card
notification.sound = Uri.parse("file:///sdcard/notification/SOUND.mp3");
// ----------------------
// Add Vibration
// ----------------------
// a. Default vibration
notification.defaults |= Notification.DEFAULT_VIBRATE;
// b. Custom vibration
long[] vibrate = {0,100,200,300};
notification.vibrate = vibrate;
// ------------------------
// Add Flashing Lights
// ------------------------
// a. Default lights
notification.defaults |= Notification.DEFAULT_LIGHTS;
// b. Custom lights
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 300;
notification.ledOffMS = 1000;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
关于Android GCM 开灯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14195067/
我想使用PHP执行一个程序,一段代码将使用RF发射器打开我的灯。这是通过命令行实现的:action63Aon这只是某人编写的一个C程序,用于控制我的树莓派上的GPIO引脚。所以我做了一个index.php它什么都不做:给我程序的默认文本输出(对要使用的参数的解释)。这告诉我PHP工作,程序位于,可以执行。但是我的灯没有打开。此外,在命令行中键入:phpindex.php是否按预期打开/关闭我的灯!(使用文件的第一个品种)Nginx(用户http)是否不允许打开/关闭灯?允许执行文件,至少可以让它生成文本输出。我也试过:还有一些变体,比如shell_exec还有想法?
我正在Android中做一个项目。我可以成功接收推送通知。收到推送通知后如何开灯?而且我还需要在收到推送通知时让我的手机振动。 最佳答案 有关更多信息,请参阅此Link.为您的list文件添加权限编辑//1.GetareferencetotheNotificationManagerStringns=Context.NOTIFICATION_SERVICE;NotificationManagermNotificationManager=(NotificationManager)getSystemService(ns);//2.Inst
洛谷传送门:P1876开灯-洛谷|计算机科学教育新生态(luogu.com.cn)难度:入门知识点:数学(因数)思路: 第n个灯会被操作多少次,取决与它有多少个因数 比如8,因数有1,2,4,8,有偶数个因数,操作完后是关灯的 比如9,因数有1,3,9,有奇数个因数,操作完后是开着的 因为一个知识点:1以外的自然数,都可以分解为两个自然数的乘积 所以,如果这个数是平方数,他其中的一对因数就是重复的,导致因数的个数变成奇数个 eg:9的因数对有(1,9)(3,3)反思: 虽然打表会超时或者爆内存,但是打表可以帮助我们找出规律 这种一下子想不出需要找规律的题目,可以先打表出来看看,
洛谷传送门:P1876开灯-洛谷|计算机科学教育新生态(luogu.com.cn)难度:入门知识点:数学(因数)思路: 第n个灯会被操作多少次,取决与它有多少个因数 比如8,因数有1,2,4,8,有偶数个因数,操作完后是关灯的 比如9,因数有1,3,9,有奇数个因数,操作完后是开着的 因为一个知识点:1以外的自然数,都可以分解为两个自然数的乘积 所以,如果这个数是平方数,他其中的一对因数就是重复的,导致因数的个数变成奇数个 eg:9的因数对有(1,9)(3,3)反思: 虽然打表会超时或者爆内存,但是打表可以帮助我们找出规律 这种一下子想不出需要找规律的题目,可以先打表出来看看,