我想从后台应用程序打开我的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();
}
但它没有打开UI。
答案 0 :(得分: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);
了解更多here