2

我想从后台应用程序打开我的 UI 应用程序。它是如何完成的?

public static void main(String[] args) {
   if (args.length > 0 && args[0].equals("MYAPP") ){
      theApp = new App();
      theApp.enterEventDispatcher();  ///this  is my ui class
   }
   else {
      BackgroundApplication app = new BackgroundApplication();
      app.setupBackgroundApplication();
      app.enterEventDispatcher();  ///this is a background application listen for push notifications
   }
}

当我收到推送通知时,BackgroundApplication应该会弹出一个警报。当我单击弹出窗口时,我希望它打开 UI 屏幕。这是怎么做到的?我试过这个:

int modHandle = CodeModuleManager.getModuleHandle("MYAPP");
     ApplicationDescriptor[] apDes = CodeModuleManager.getApplicationDescriptors(modHandle);
     try {
        ApplicationManager.getApplicationManager().runApplication(apDes[0]);
     } catch (ApplicationManagerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }

但它没有打开用户界面。

4

1 回答 1

3

您应该将参数“MYAPP”传递给正在运行应用程序的代码:

ApplicationDescriptor[] appDescriptors =
CodeModuleManager.getApplicationDescriptors(
        CodeModuleManager.getModuleHandle("MYAPP"));//.Cod file name
ApplicationDescriptor appDescriptor = new ApplicationDescriptor(
appDescriptors[0], new String[] {"MYAPP"});
ApplicationManager.getApplicationManager().runApplication(appDescriptor);

在这里阅读更多

于 2012-07-19T08:36:12.960 回答