internal static extern ErrorCode AppContextGetPid(IntPtr handle, out int processId);
//int app_context_get_pid (app_context_h app_context, pid_t *pid)
+ [DllImport(Libraries.AppManager, EntryPoint = "app_context_get_app_state")]
+ internal static extern ErrorCode AppContextGetAppState(IntPtr handle, out int state);
+ //int app_context_get_app_state (app_context_h app_context, app_state_e *state)
+
[DllImport(Libraries.AppManager, EntryPoint = "app_context_is_terminated")]
internal static extern ErrorCode AppContextIsTerminated(IntPtr handle, out bool terminated);
//int app_context_is_terminated (app_context_h app_context, bool *terminated);
Dispose(false);
}
+ /// <summary>
+ /// Enumeration for the Application State.
+ /// </summary>
+ public enum AppState
+ {
+ /// <summary>
+ /// The undefined state
+ /// </summary>
+ Undefined = 0,
+
+ /// <summary>
+ /// The UI application is running in the foreground.
+ /// </summary>
+ Foreground,
+
+ /// <summary>
+ /// The UI application is running in the background.
+ /// </summary>
+ Background,
+
+ /// <summary>
+ /// The Service application is running.
+ /// </summary>
+ Service,
+
+ /// <summary>
+ /// The application is terminated.
+ /// </summary>
+ Terminated,
+ }
+
/// <summary>
/// Gets the application id.
/// </summary>
return label;
}
+ /// <summary>
+ /// Gets the state of the application.
+ /// </summary>
+ public AppState State
+ {
+ get
+ {
+ int value = 0;
+ IntPtr contextHandle = IntPtr.Zero;
+ try
+ {
+ err = Interop.ApplicationManager.AppManagerGetAppContext(ApplicationId, out contextHandle);
+ if (err != Interop.ApplicationManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the context handle. err = " + err);
+ }
+ err = Interop.ApplicationManager.AppContextGetAppState(contextHandle, out value);
+ if (err != Interop.ApplicationManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the app state. err = " + err);
+ }
+ }
+ finally
+ {
+ if (contextHandle != IntPtr.Zero)
+ {
+ Interop.ApplicationManager.AppContextDestroy(contextHandle);
+ }
+ }
+ return (AppState)value;
+ }
+ }
+
private IntPtr GetInfoHandle()
{
if (_infoHandle == IntPtr.Zero)