How to call Midlet class after button click in j2me? - java-me

When i click on button in first midlet class i need to redirect to next midlet Class. How to do this
if(sb.toString().equals("SUCCESS")){
Alert success = new Alert("Login Successfully",
"Your Login Process is completed!",
image, AlertType.INFO);
// success.setImage(image);
userName.setString("");
password.setString("");
display.setCurrent(success, form);
// here i move to next midlet
}

If both MIDlets are part of the same MIDlet Suite, then they should be able to launch each other using Class.forName().
Quote from Sun back in the day:
"For security reasons, it is assumed that MIDlets within a MIDletSuite are packaged together for a reason and should be able to interoperate. What's implied here is that the MIDlets share a name space; in other words, each MIDlet in the MidletSuite can "see" one another. Because they can see one another, they can launch one another (Class.forName metaphor)."
If the two MIDlets are not part of the same MIDlet Suite, then there is this following trick. I haven't tried it myself though, so it's only theoretical:
For the MIDlet you wish to launch from another MIDlet, you put a PushRegistry entry in the JAD (or register it by code), listening for a socket connection on some port.
Then to launch the MIDlet from another MIDlet, you simply create a socket connection on that port using localhost or 127.0.0.1 as address. That should theoretically make the other MIDlet launch.

Related

Adding Dynamic Cast Button to Android Application

From the Google documentation about adding a Cast button, https://developers.google.com/cast/docs/android_sender#adding-the-cast-button , it seems like the option they provide is for us to add a static button to the Action Bar. That said, what would I do if I wanted to add a Cast Button to my application only if there's a device on the network dynamically? Also, what are some ways you would create a custom button that mimic the functionality of a MediaRouter Button.
Any input would be appreciated!
Based on your response in the comments, it seems like you want the normal behavior of a cast button, provided by, say, the MediaRouteActionProvider except that you don't want the cast discovery to include "guest mode". Is that a fair rephrasing of your question? If that is the case, then you can simply use the MediaRouteActionProvider and when you add your app in the developer console, you can uncheck the box that says "Supports Google Cast Guest Mode". Then guest mode (i.e. discovery of your app when not on wifi) is disabled for app and only devices that are on the same wifi network as your phone will be discoverable for your app.
After following the steps for incorporating cast in your application. Eg https://github.com/googlecast/CastHelloText-android/blob/master/src/com/example/casthelloworld/MainActivity.java Create an android button and call the following method in the button
public void connect() {
android.media.MediaRouter mMediaRouter = (android.media.MediaRouter)getApplicationContext().getSystemService(Context.MEDIA_ROUTER_SERVICE);
mMediaRouter.selectRoute(android.media.MediaRouter.ROUTE_TYPE_USER,mMediaRouter.getRouteAt(1));
}
This automatically connects to the chromecast and calls the #Override
public void onRouteSelected(MediaRouter router, RouteInfo info) method.

Logging out of managed chromebook running in single app kiosk mode

I am a 'Chrome for Business and Education' admin for a fleet of chromebooks which I have configured to run in Single App Kiosk mode. The kiosk app in question is really simple. All I did was take the example code from this page that uses the 'webview tag' (without controls, as we need all the whole screen for the app in question) and change the URL. The app has installed perfectly in all managed devices.
The problem now is that there are times when we want to be able to exit the kiosk app and return to the chromebook login screen. Right now the only way of doing this is to shut the machine down, start it and exit from the kiosk app boot screen by pressing Ctrl+Alt+S. The whole process takes 30 seconds plus per machine (the fleet contains 50). So we really need to be able to just quit out of the kiosk app and go back to the login screen (which would take about 5 seconds or less).
Now, I could just add a quit button to the screen (as per the second example app with navigation controls from the page referenced above) but this means we lose screen space for the app. The preferred solution is to close the app with keystrokes (e.g. Ctrl+Shift+L). But how do you do this in this context? I have tried adding conventional onkeydown javascript to the page containing the webview tag and this seems to be ignored. I have also tried using the 'chrome commands API', and whilst I can see that the shortcut had been registered against the extension (by clicking 'Keyboard shortcuts' on the chrome://extensions tab) it has no effect. The kiosk app window remains stubbornly open.
Does anyone know if this is possible and if so how?
Cheers,
Miles
In your manifest.json file add this entry to create the command for the app.
"commands": {
"exit-app": {
"suggested_key": {
"default": "Ctrl+Shift+L"
},
"description": "Exit the app"
}
}
Then you need to add code to your background script file to listen for the command. This code will close all windows in the app when it receives the exit-app command you created in the manifest.
chrome.commands.onCommand.addListener(function(command) {
switch(command) {
case 'exit-app':
exitApp();
break;
}
});
function exitApp() {
chrome.app.window.getAll().forEach(function(win) {
win.close();
});
}
Note that the key combination is only suggested, and might be ignored if another app or Chrome keyboard shortcut already uses that combination. You do still need to go to the Keyboard shortcuts link on the chrome://extensions page and verify that the key combination has actually been set for your app.

Chrome Extension + Getting Hang while any dialogue comes while opening a page

I have created one extension to test my website, which will open page and do some activity like set text, get text etc etc.
I have created one C# application and via websocket I will communicate with extension.
In my extension I have added listener as below,
document.addEventListener('DOMContentLoaded', function() {
websocket.send(""); // Send signal to C# to execute next command
});
so when I will open any website e.g www.google.com, it will fire above event and my next action will come to execute, but issue is while I open any website which will have alert box at the first stage of loading page, will never execute above listener e.g If I will open http://www.crowderassoc.com/javascript/alertbox.html, it will give you an alert message, till your click on OK, the page will be busy and so It will get stuck.
I am created automated script, in which I will place one MSAA command to click on that "OK" button, but my it just got hanged.
Is there any option that I can make it work in this situation?
Move code of DOMContentLoaded Listener
document.addEventListener('DOMContentLoaded', function() {
websocket.send(""); // Send signal to C# to execute next command
});
in Content Scripts to listener of tabs.onUpdated or any of webRequest, webNavigation Appropriate Listeners in Background Page.

Show alert about internet connectivity before launching the application (Monotouch)

I am developing an app that requires an internet connection, so I want to check the availability before launch.
If internet connection it is not available, show an alert to the user and go back to Home instead of trying to launch the app.
So I used the Reachability class, that was recommended here (http://stackoverflow.com/questions/1961341/check-for-internet-access-with-monotouch) to check the internet connection.
So far so good. But if I place this check in my Main.cs, it performs the check, but will not display the alert.
if(!Reachability.IsHostReachable("http://google.com")) {
Debug.WriteLine("OFFLINE");
UIAlertView alert = new UIAlertView("Offline","Voor deze app is een internetverbinding vereist.",null,"OK",null);
alert.Show();
}
else{
MPFramework.Application app = new MPFramework.Application();
UIApplication.Main (args, null, "AppDelegate");
}
If I place this check in AppDelegate.cs it performs the check, displays the alert, but keeps a black screen instead of returning to Home.
So where do I place my code in order to check before launching the app, and displaying an alert?
You're looking at this a bit wrong:
Apple doesn't approve of apps that kill/close themselves (see this: https://stackoverflow.com/a/356342/183422). If the user wants to close your app, he should do it himself.
You need the main loop running to show any UI - and that main loop is started when you call UIApplication.Main (which is why you have to do the check in AppDelegate.cs and show the corresponding alert there instead of in your Main method).
So, putting these things together, I think you should show a blank/splash screen, check for reachability and if there is none then show the alert (and if the user dismisses the alert, maybe check again).

How to resume iPhone app after a Phone Call

I am creating an iPhone app in which I am providing a call feature with the help of which a user can call place a call on a specified number. I am able achieve the above feature via open URL.
Now after completion of the call I want to resume the execution of app automatically. Although a user can make a fast app switch in iOS 4.0. but I want this to be done automatically.
I have seen the same behavior in "TomTom" app but I am not sure how this app has achieved it.
Thanks
Sandy
Apple does not allow you to resume an app after a phone call. What you can however try doing is using a local notification.
After calling the 'call' url handler you will need to start a background task and monitor for a call state change:
CTCallCenter *c=[[CTCallCenter alloc] init];
c.callEventHandler=^(CTCall* call){
if(call.callState == CTCallStateDisconnected) {
// do stuff here
}
}
When you get a call state change, create a local notification to alert the user to resume the app. If the user taps on "view" your application will then come to the foreground. Obviously if the call is longer than 10 minutes this won't work as Apple only allows 10 minutes to background tasks.

Resources