[TIMOB-24629] Android: Add wakeLock to NotificationManager
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-08-28T18:34:14.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.2.0 |
Components | Android |
Labels | android, notification |
Reporter | Michael Gangolf |
Assignee | Gary Mathews |
Created | 2017-04-25T18:46:19.000+0000 |
Updated | 2018-09-07T01:29:24.000+0000 |
Description
Add the possibility to add a wakeLock to http://schemas.android.com/apk/res/android">
{noformat}
* start the app
* click the button and lock the device
* notification will appear and screen turns on
It will stay on the
Titanium.Android.Notification
to switch on the screen when a Notification is fired
*Example:*
var win = Ti.UI.createWindow({});
var btn = Ti.UI.createButton({
title: "click"
});
win.add(btn);
btn.addEventListener("click", function() {
_.delay(function() {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_MAIN,
className: 'com.appcelerator.notificationsample.NotificationsampleActivity',
packageName: 'com.appcelerator.notificationsample'
});
intent.flags |= Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_ACTIVITY_NEW_TASK;
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
var pending = Titanium.Android.createPendingIntent({
intent: intent,
flags: Titanium.Android.FLAG_UPDATE_CURRENT
});
var notification = Titanium.Android.createNotification({
contentTitle: 'Something Happened',
contentText: 'Click to return to the application.',
contentIntent: pending,
wakeLock: 100
});
Titanium.Android.NotificationManager.notify(1, notification);
}, 4000);
});
win.open();
Add permission to tiapp.xml
{noformat}
wakeLock
time (+normal screen on time)
PR: https://github.com/appcelerator/titanium_mobile/pull/8990
https://developer.android.com/reference/android/os/PowerManager.html#newWakeLock(int,%20java.lang.String) There is more then one paramter (time). I think wee need more then one options => KrollDict
I'll have a look at the parameters. In most cases the default parameter is enough because you would just need to turn the screen on (which is better than the current solution not to do it :-) ). But it might be useful to have the levelAndFlags exposed.
This more a
Feature
than aBug
right? :-) Scheduling for 6.2.0.Yes, it's a new feature. I've changed the parameter and the example is :
6_2_X: https://github.com/appcelerator/titanium_mobile/pull/9307
Failing review. Please see master PR for info.
FR Passed for master PR. Master PR merged.
FR Passed for 6.2.0 PR & merged.
Verified the fix in SDK 6.2.0.v20170828180251 & 7.0.0.v20170828180637. Closing. Studio Ver: 4.9.1.201707200100 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.9 Appc CLI: 6.2.3 Ti CLI Ver: 5.0.14 Alloy Ver: 1.9.13 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1 ⇨ Motorola G2 --- Android 4.4.4