Video playback asks about security timer reset - java

I am developing a BlackBerry app which can play video. The first time the video starts playing (works fine) it asks with a dialog,
"The application xyz is attempting to reset the security timer. "
Checkbox:
Do not ask again
And the option
Allow / Deny
If allow is choosen and the checkbox selected, the video plays without problem the next time. But is it a way to remove this security timer question before the video is even played?
This is a related or same issue over at the RIM support site.

The dialog you are seeing is the OS prompting the user to grant your application permission to a restricted API call. Even though you are not directly resetting the security timer in your code, it is being done on your behalf as part of your app. The best way to handle this is to prompt the user for permission the first time the user runs your app.
Below is a sample method that prompts the user for all permissions. You should call this the first time your application runs. You could be more selected in what you prompt for by calling permRequest.addPermission( int permission ) for only the permissions that you need. For example pass ApplicationPermissions.PERMISSION_IDLE_TIMER.
private static void assertHasPermissions()
{
// Capture the current state of permissions and check against the
// requirements.
ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance();
ApplicationPermissions original = apm.getApplicationPermissions();
ApplicationPermissions permRequest = new ApplicationPermissions();
int[] permissions = original.getPermissionKeys();
for ( int i = 0; i < permissions.length; i++ )
{
permRequest.addPermission( i );
}
apm.invokePermissionsRequest( permRequest );
}
http://supportforums.blackberry.com/t5/Java-Development/Enable-the-backlight-and-prevent-the-BlackBerry-device-screen/ta-p/444706

This is just a guess...
It may be that when you start playing the video, the OS assumes a request to reset the security timer so that the device will not lock while the video is playing. It may be easier to be sure if you let us know what version of the device software you are running, and what version of the API you are programming with.

Related

How to init asking admin's pattern in my code?

I'm developing app for Zebra device model MC33.
I like how internal apps ask to enter admin pattern (password) when I open Settings or others. In my app I have settings activity and I would like to ask user for authorization.
What I want to have is:
https://imgur.com/gallery/BwpAAPI
I used class DevicePolicyManager and then call for lock screen. (code is below)
But it turn off the sceen completely (it become black) like the device is switch off. Then I can enter pattern to turn it on.
This is screenshot what I get after using DevicePolicyManager:
https://imgur.com/gallery/TnHgDgs
DevicePolicyManager policy = (DevicePolicyManager)
getSystemService(Context.DEVICE_POLICY_SERVICE);
policy.lockNow();
Such behaviour may be misleading. Do you have idea how to call for proper screen in my app?

onTaskRemoved not being called in service above android 6.please can some one give better alternative

I've been using onTaskRemoved() method in a Service to detect when an app was removed from the device's RECENT list by swiping it away. I preform some logging and some other operations that need to take place when this happens. It works perfectly. For android below 6... But background service is being killed after swiping off in android 6.
#Override
public void onTaskRemoved(Intent rootIntent) {
Log.e("ClearFromRecentSsss", "sttttts");
Intent intent = new Intent("in.com.example");
sendBroadcast(intent);
}
Some manufactures like xiaomi, Oppo have their own background strategy which is autostart. You need to redirect user to auto start activity and tell user to switch on:
Go like this and allow your app to autostart:
Settings > permissions > Autostart
Autostart setting varies by manufactures like in Xiaomi you can find it in their SecurityCenter app.
Autostart is blocking your service to restart, So turn it on manually and the check again . I'm afraid there is no inbuilt API to do so . So you need to redirect users to specified screen as per manufactures to turn auto start On. Have a look at Links below:
link1
link2

codename one local notifications not working on ios

I have added a local notifications so when my app gets a push while opening there is still a popup and a sound.
It's working fine on Android, but on iOS the local notification doesn't appear at all.
The push notifications are working fine on both platforms.
This is my code in the push callback that should trigger the notification (if the app is open):
if(Display.getInstance().getCurrent() != null) {
LocalNotification n = new LocalNotification();
n.setId(value);
n.setAlertBody(value);
n.setAlertTitle({app name});
n.setBadgeNumber(1);
Display.getInstance().scheduleLocalNotification(n, System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);
}
Local notifications don't fire while the app is open in the foreground. You should use a different mechanism to make a sound while the app is running. Eg Display.vibrate()
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
[[NSNotificationCenter defaultCenter] postNotificationName:#"DriverNotification" object:nil userInfo:userInfo];
// [[NSNotificationCenter defaultCenter] postNotificationName:#"UserNotification" object:nil userInfo:userInfo];
NSLog(#"%#",userInfo);
}
Put This Code in Your View Controller
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(receiveNotification:) name:#"DriverNotification" object:nil
];
Did you call registerUserNotificationSettings to register the fact that your app uses local notifications? If you don't do that, your request to post a local notification will be ignored.
See this text from the description of that method:
If your app displays alerts, play sounds, or badges its icon, you must
call this method during your launch cycle to request permission to
alert the user in these ways. (You must also make this request if you
want to set the applicationIconBadgeNumber property directly.)
Typically, you make this request if your app uses local or remote
notifications to alert the user to new information involving your app.
The first time your app launches and calls this method, the system
asks the user whether your app should be allowed to deliver
notifications and stores the response. Thereafter, the system uses the
stored response to determine the actual types of notifications you may
use.
After calling this method, the app calls the
application:didRegisterUserNotificationSettings: method of its app
delegate to report the results. You can use that method to determine
if your request was granted or denied by the user.
It is recommended that you call this method before you schedule any
local notifications or register with the push notification service.
Calling this method with a new user settings object replaces the
previous settings request. Apps that support custom actions must
include all of their supported actions in the notificationSettings
object.
you need to add below code in didFinishLaunchingWithOptions method of AppDelegate.m file for register local notification
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[UIApplication sharedApplication] respondsToSelector:#selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
}

what is the different ways to require FB like permissions?

Can someone explain what is the difference in getting permissions in one of the two:
1) via code, on first Fb login:
setContentView(R.layout.facebook_login);
LoginButton authButton = (LoginButton) findViewById(R.id.authButton);
// authButton.setReadPermissions(Arrays.asList("user_status"));
authButton.setReadPermissions(Arrays.asList("basic_info",
"user_birthday", "user_interests", "user_likes", "email",
"user_location", "publish_actions"));
2) via Facebook developer page:
if there is none, what is the duplication?
App Details --> Configure App Center Permissions
In (1), i.e. in code, you can choose at execution time which permissions to ask for. This means you can, for example, initially ask for just public_profile, and then later when the user wants to share something you can ask again for "publish_actions".
In (2), you are setting which permissions the user will grant if they start playing via the app centre (e.g. https://www.facebook.com/appcenter/yourgame). In this case the set of permissions you choose will be shown to the user in the app center before they start your game. When they press Play in the app centre they are granting the chosen permissions, so you don't need to call a login method from within your code.
These two sets of permissions can be different.

Blackberry dialog launched on PhoneListener's callInitiated method

Hy.
I have a situation with an UiApplication for Blackberry 5.0.0 OS that may be of interest to the communnity or with wich someone could help me.
My application implements the PhoneListener interface to be notified when an outbound call is detected on the device (callInitiated method). Upon that, the app simulates a disconnect key press to cancel the call. Then, a Dialog is launched and some action is required on the user side...
All works well when the number is dialed through the phone app, the dialog is launched, the phone app dissapears and the dialog remains on screen waiting for user action. But if the user dials through the contacts list, speed dial or numbers in web pages, the dialog appears but quickly dissapears when the phone app dissapears (after the call is artificially disconnected).
I'll be paciently awaiting for a response from someone that can shed some light on this... thanks.
The solution:
The dialog must be created in another way. I was using Dialog.ask by the way.
Screen screen = null;
synchronized(UiApplication.getEventLock()){
UiEngine ui = Ui.getUiEngine();
screen = new Dialog("<dialog text>", <options>, <values>, 0, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION));
ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_MODAL);
}
int appMethodAsked = ((Dialog) screen).getSelectedValue();
To note that, a key detail for this code to work is the UiEngine.GLOBAL_MODAL value passed to the pushGlobalScreen method. Without this, the same thing described as the problem will happen.

Categories