In Samsung gear S3, I want to develop a Tizen native service application which continously checks if a web application is running or not and launches the web application if its not running.
By continously, I mean it can be either checking every minute or adding an event listener (for state change of application).
I wanted to do this because my web application is getting terminated after some time (may be after a day or so) but I want it to run always in background.
Right now,I was able to launch the web application from service application with the following code.
app_control_h app_control;
int ret = APP_CONTROL_ERROR_NONE;
ret = app_control_create(&app_control);
if (ret != APP_CONTROL_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "app_control_create() is failed. err = %d", ret);
ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
if (ret != APP_CONTROL_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "app_control_set_operation() is failed. err = %d", ret);
app_control_set_app_id(app_control, "08CCMUEFHN.ROAMMprompt");
ret = app_control_send_launch_request(app_control, NULL, NULL);
if (ret != APP_CONTROL_ERROR_NONE)
dlog_print(DLOG_ERROR, LOG_TAG, "app_control_send_launch_request() is failed. err = %d", ret);
Please help me in developing code to continuously check if my web application is running or not.
Instead of Developing additional Native Service application, Your Web application can itself Do your desired task.
Tizen Alarm API enables you to schedule an application to be run at a specific time. When an alarm is triggered, the application is launched (unless it is already running).
Register a repetitive alarm using Web Alarm API that would Launch the Web app itself after your desired time frame.
var appId = "com.samsung.clocksetting";
// Your desired appId, in this case 'settings' app
var alarmR = new tizen.AlarmRelative(2* tizen.alarm.PERIOD_MINUTE, 30 * tizen.alarm.PERIOD_MINUTE);
// Set an alarm in system that would trigger after 2 minutes and then every 30 minitues
tizen.alarm.add(alarmR, appId);
Add 'alarm' privilege in your config.xml. Check out these Links for details implementation:
Tizen Web Alarm Guide
Tizen Web Alarm API References
Related
I have a PWA application where I check whether the application is in standalone mode(code snippet below) else prompt user with the Install Banner.
let windowNav: any = window.navigator;
if (window.matchMedia('(display-mode:standalone)').matches || windowNav.standalone) {
this.isStandAlone = true;
}
Recently, I have also created a TWA app for the same. Now when I install the APP from the playstore the below check fails though the app is in standalone mode. Is there a different way to check the standalone mode in TWA applications?Or a way to check that the APP is a TWA app?
Thanks
Standalone is not so useful in case of TWA.
if u want to know that your application is running on TWA,
What you can do is set a sessionStorage as a flag,
If certain conditions met. When ever a TWA app is open u can get the package name like com.example inside document.reffer property and also you can pass some value in query Param to check ur app. Is opened.
So, this will look like this.
If(document.referrer == 'android-app://com.example' && location.href.includes('?twa=true')){
sessionStorage.isTwa = 1;
}
When app opens, a session starts, and isTwa will be set as 1, when app is closed that session ends as well. Same as a chrome tab session.
I am developing a mac application in which I am showing some count on app icon symbol (Similar to notification count). It work fine when app is in foreground and is active. But as an when I minimise the app or app goes into background. I am not able to see any message count on icon symbol.
let app = NSApplication.sharedApplication()
app.dockTile.showsApplicationBadge = true
app.dockTile.badgeLabel = String(unrdcount)
This method is called when I am getting data from a particular API. Can anyone suggest me how to let a particular API work for infinite time, so that if the application is ON user can get this unrdcount from API.
I am using google places api in ionic app.I places google places api script in index.html. The app allow the user to access wifi within specific place. User get internet access after login with our app. When application launch and user is connecting with our network, user do not have access to the internet. So i get error:
Application Error connection to the server was unsuccessful.
Is there anyway to call the google places api after user has access to the internet to avoid the error?
This has been quickly tested in ionic 1 and it works, no reason it shouldn't in ionic 2. But if you know a proper way to add the script tag in angular, just replace this part. The logic is simply to add your resource on the fly to index.html. Don't forget that connexion can appear while app is already started, and that you don't need to add the tag twice (verifications have to be done). Some edits might be done to adapt to ionic 2, sorry my version was made on the 1.
the function to add the script:
function addScriptTag(){
//STORE HERE VALUE TO VERIFY SCRIPT HAS ALREADY BEEN ADDED
var script = document.createElement('script');
script.src = 'http://maps.google.com...';
script.type = 'text/javascript';
document.head.appendChild(script);
}
in $ionicPlatform.ready (network is not available before that)
//CONNECTED AT APP LOADING
var networkState = navigator.connection.type;
if(networkState !== Connection.NONE){
addScriptTag();
}
//IN CASE CONNEXION ARRIVES LATER
$rootScope.$on('$cordovaNetwork:online', function(event, networkState){
if( /* VERIFY SCRIPT NOT ADDED BEFORE */ ){
addScriptTag();
}
}, false);
I am creating an app using Phonegap 3.1, Sencha 2.3 for the platform android and iPhone.
For sending notification, i have used pushwoosh service and followed this link (http://www.pushwoosh.com/programming-push-notification/ios/ios-configuration-guide/)
Notification are getting perfectly on both Android and iPhone devices (whether app is running or not).
But the problem is, when I reinstall the app, i am not able to get notifications when the app is running and notifications are getting when app is minimized or not running.
In my index.html file, I have used this code to receive the notification while app is running.
document.addEventListener('push-notification', function(event) {
alert('push-notification');
var notification = event.notification;
navigator.notification.vibrate(1500);
navigator.notification.confirm(
notification.aps.alert, // message
alertDismissed, // callback
'ThisApp', // title
'Done' // buttonName
);
pushNotification.setApplicationIconBadgeNumber(0);
});
function alertDismissed() {
//do something after Done button pressed
}
After reinstall the app this listener is not calling.
I am not getting what actually missing in there, please advise.
I am using Blackberry Facebook SDK (FacebookBlackBerrySDK-v0.8.25.jar) for facebook integration for my app. I am using the following code.
ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID, APPLICATION_SECRET, PERMISSIONS);
Facebook fb = Facebook.getInstance(as);
try{
FBUserDetails fbUserDetails = FBUserDetails.getInstance();
String prevUserDatails = fbUserDetails.getFBData();
User user = fb.getCurrentUser();
if(prevUserDatails != null && !prevUserDatails.equals("") && user.getEmail().equals(prevUserDatails)){
if(Dialog.ask(Dialog.D_YES_NO,"Do you want to post using FB account " + prevUserDatails + "?",Dialog.YES)==Dialog.NO){
fb.logout(true);
user = fb.getCurrentUser();
}
}
if(user!= null){
fbUserDetails.persist(user.getEmail());
String result = user.publishStatus(decodedText);
if ((result != null) && !result.trim().equals("")) {
Dialog.alert("Successfully posted to Facebook.");
} else {
Dialog.alert("Share Failed.");
}
}else
Dialog.alert("user is equal to null.");
}catch(FacebookException fe){
fe.printStackTrace();
}
When I am testing the app in Blackberry Strom 9300 (OS version 6.0.0.526), it is running properly first time. But when I am going to share the same text again in a short interval(it is obvious that the posting will fail), system is giving "the memmory available on your device is low. Close some of the items below." and I forced to close the application. Can anyone tell me what is the problem in the above code?
I am having the same issue with my Webworks Blackberry build. The first time I begin using the app it is running fine but when I begin to process other pages on the app I receive a pop-up telling me that "the device memory is too low - please close the following items". Then the app icon changes to what looks like a folder.
I did some research and it appears this is a persistent problem on the Blackberry OS 6. Deleting the app and reinstalling it does not help neither does restarting the app.
Take a look at this link to view deeper issues related to low device memory
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Device-memory-is-Low-issue-for-an-WebWork-app/td-p/1166441/page/16