How to launch com.android.launcher explicitly? - android-launcher

I have an app that replaces the launcher for a kiosk application. I need to exit to the stock launcher for service mode.
From a dummy test app I can start my own "home" app like this:
Context ctx = getBaseContext();
Intent i = ctx.getPackageManager().getLaunchIntentForPackage("my.application.main");
ctx.startActivity(i);
However, if I replace my.application.main with com.android.launcher, I get back null for the intent. Yet, com.android.launcher is on the system (Nexus 7 tablet). How do I launch com.android.launcher explicitly?

Related

Unable to run test on real device but running on simulator

As I am new to real-time device testing, I need your support in resolving an issue which I am facing since long now. I have following issues with iOS devices and simulators:
I am able to run my script in the simulator but not on the real-time device.
Unable to see WebDriverAgentRunner app on the device, however, I have built that app multiple times.
My Scrip is able to interact with Appium, it gets installed also but never gets open (In Eclipse it gets failed with error: No element found)
Please find the attached appium logs and desired capabilities below:
Desired Capabilities:
IOSDriver wd = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
System.out.println(" ");
capabilities.setCapability("appium-version", "1.7.2");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("udid", “UDID”); //6Plus
//capabilities.setCapability("noReset", "true");
capabilities.setCapability("platformVersion", "11.2.6");
capabilities.setCapability("deviceName", "iPhone 6”);
capabilities.setCapability("app",
“<Path of builded Application.app>”);
capabilities.setCapability("bundleID", “<com.bundel id>”);
wd = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"),
capabilities);
Also in the simulator, I am able to run only on one device.
Appium Logs Are present in this link

How to find the current activity of an app in ios

I am using Appium for IOS testing. (java) I want to be able to check the current activity of an app . In the sense when an App switches from clickable to another (say I close the app or switch to another app or open the notifications scroll. I want to be able to detect the page name. To get the current activity name, i use driver.currentActivity(); which is included in the AndroidDriver class.
but There is no direct call for current package in ios, but many suggested that can be found out by looking at the attributes of existing elements in the device screen by calling driver.getPageSource(); how can I achieve this using driver.getPageSource or is there any other way to do it?Any advise on this would be helpful.
You can query current app state, if you have the bundleId of the app then you can
query it's state if its running in background or foreground and it solves your problem.
Map<String, Object> params = new HashMap<>();
params.put("bundleId", "com.myapp");
final int state = (Integer)js.executeScript("mobile: queryAppState", params);
There can be 5 possible state as per the documentation.
0: The current application state cannot be determined/is unknown
1: The application is not running
2: The application is running in the background and is suspended
3: The application is running in the background and is not suspended
4: The application is running in the foreground
Refrences
To see if your app is running, assuming you know the bundleId, you can use the driver directly:
driver.queryAppState('com.apple.Preferences');
It returns the ApplicationState:
NOT_INSTALLED,
NOT_RUNNING,
RUNNING_IN_BACKGROUND_SUSPENDED,
RUNNING_IN_BACKGROUND,
RUNNING_IN_FOREGROUND

Why won't Application Insights data show in my dashboard when reported from a Background Task?

I've got MS App Insights data being logged from a Background Task when it runs. However, though I receive no exceptions from AI when debugging the code, nothing is showing in my dashboard as I would expect. All other telemetry from the same session (in main app, not Background Task) logs just fine.
I'm attempting this on Windows 10 Mobile with AI pkg v1.2.3
You might need to .flush() the TelemetryClient periodically, or before your Background Task exits.
Turns out the key was utilizing the new PersistenceChannel as the Channel for my Telemetry like so:
TelemetryConfiguration.Active.TelemetryChannel = new PersistenceChannel();
then in my bg task:
var c = new TelemetryClient() { InstrumentationKey = <my app insights key> };
c.TrackEvent(evt);
c.Flush();
The documentation for PersistenceChannel shows how it does what AI previously did automatically: cache results to local storage until they're able to be sent to the AI service.
This enabled my background task to fire off and cache its analytics until such time that the user launched the app (and therefore the AI objects got access to the backend service) or the bg task had enough time & muscle to do it itself.

HKWorkoutSession isn't keeping app at front of Apple Watch

It has been stated that an app running a HKWorkoutSession will have special privileges over other watchOS 2 apps, so when a user looks at their Apple Watch, it will go to the view showing running a workout rather than the watch face.
Currently, on both my device and simulator, this is not the case. If I start a HKWorkoutSession and then leave for 5 minutes and then interact with either the Apple Watch, or the Watch Simulator, it presents the watch face.
If I then open my app, it appears to have been frozen, rather than terminated (which is what I imagine happens to other apps). As the UI will update when I need receive a response in my query.updateHandler. Also if I set it to provide haptic feedback every time my query.updateHandler receives a new HKQuantitySample it will do so, so the app must be running in the background in some form.
Has anyone else noticed this behaviour, and am I doing anything wrong, or expecting something I shouldn't?
Here is how I start my HKWorkoutSession:
self.workoutSession = HKWorkoutSession(activityType: HKWorkoutActivityType.Other, locationType: HKWorkoutSessionLocationType.Indoor)
self.healthStore.startWorkoutSession(self.workoutSession) {
success, error in
if error != nil {
print("startWorkoutSession \(error)\n")
self.printLabel.setText("startWorkoutSession \(error)")
self.printLabel.setTextColor(UIColor.redColor())
}
We're seeing that too, for the moment we've made sure 'opens last activity' is configured.
When the UI is active we start a dispatch_timer to request and process data in 1 second intervals.
Make sure you do any significant processing using the NSUserProcessInfo method though and pause the dispatch_timers whenever you are no longer active. You'll get crashes otherwise.

How to open a console app from a webform

I have a collection of sites running on a single server. The server also runs a console application which collects data and distributes this data to the websites.
I am not always about to check if the application is running and I would like to give the end user (a select few users!) the option to start/restart this application on the server by using a webform. (click a button and application starts).
I have got the console application to start by using the following code:
ProcessStartInfo info = new ProcessStartInfo(FileName);
Process App1 = null;
App1 = Process.Start(info);
But no console window appears and I would like the console to open a window so that if I log onto the server I can check that the application is running.
I have tried adding:
info.CreateNoWindow = false;
and a few other things, but this is not my area so I am struggling.
Any ideas how I can get the console to open in a normal window? Or am I going about this all the wrong way?
Also, is there a way of finding if the application is running and either kill it before trying to start it, just restarting it, or not allowing the end user the option to do anything.
Many thanks
T
As Aristos says, the console app will open on the server...not the client.
Look here for a start on how to open a process from asp and the security implications
If you need the client to be able to view anything I suggest having the service write to a log in a database and having the aspx page read this log.
Also, maybe write your console app as a windows service, not just an application?
Good example here
Hope this helps.
ProcessStartInfo info = new ProcessStartInfo(FileName);
Process App1 = null;
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
App1 = Process.Start(info);
try using info.usershellexecute property

Resources