How to invoke an application in embedded mode?

Login to reply to this topic.
Wed, 2004-07-28 16:23
Joined: 2004-07-27
Forum posts: 14
Hi.

I alreay know how to invoke an application using the CApaCommandLine but now i need to invoke a specific application in embedded mode.  Roll Eyes  

Is it possible? or it's only possible to open a document and the document handler opens the associated application?  Cry

Thu, 2004-07-29 15:05
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
It's not only Document Handler
Hi,

You can embed an application as follows:
- You have to identify the host application whose content the embedded application will be running in,
- You have to create (actually add) a new document to the host application,
- You have to call the newly added doc's EditL method in order to create an app ui (among other things),
- Finally an optional thing: you may pass a filename to the doc.

How does it look like in practice?

Code:
/* Launch the appropriate application in embedded mode */
CEikProcess*  hostProcess = CEikonEnv::Static()->Process();

CEikDocument* newDoc = (CEikDocument*)hostProcess->AddNewDocumentL(
_L("Z:\\system\\apps\\xxx\\xxx.app"), xxxUID );

newDoc->EditL( this, ETrue );   // "This" acts as observer.

RFs fs;
User::LeaveIfError( fs.Connect() );
CleanupClosePushL<RFs>( fs );

newDoc->OpenFileL( ETrue, _L("A file name"), fs );

CleanupStack::PopAndDestroy();  // close fs

Cheers,

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Fri, 2004-07-30 02:13
Joined: 2004-07-27
Forum posts: 14
How to invoke an application in embedded mode?
Thanks Tote

I've managed to start the application embedded but only when i am passing NULL to the newDoc->EditL()  Huh

I need my application to detect that the embedded application has exited, and i'm not having success to pass an Observer to do that.

I've already derived a class from MApaEmbeddedDocObserver with the NotifyExit method implemented and created an instance and passed that to the EditL with no success Cry

I've try too derive my CEikDocument class from MApaEmbeddedDocObserver like this:

Quote
class CMyProgDocument : public CEikDocument, public MApaEmbeddedDocObserver

And inside my Document class i called newDoc->EditL(this,ETrue) and with no success either.

What i want is that my application exits imediatly after the embedded application exits.

Help please, i don't know if i am making some very newbie mistakes, i am new to Symbian.
Fri, 2004-07-30 13:21
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
How to invoke an application in embedded mode?
Hi,

That's interesting. Shocked We use a simple CBase-derived object (not a CEikDocument) that additionally implements MApaEmbeddedDocObserver mixin as well. And everything works fine.

We call EditL like this:

Code:
iDoc->EditL( this, ETrue );   // "This" acts as observer.

where "this" is certainly the object I was talking about above.

Anyway, first, this is the right way to be notified upon exit, but there're two things I still think good to know.
1.) DestroyDocument: I forgot to mention one thing. When the embedded application exists, it most probably does it so that only its app ui gets deleted and of course, all those objects that are owned (implicitly or explicitly) by the app ui. So the document object itself will NOT be deleted and thus, you have to do it yourself. You can do it like this:

Code:
void CYourExitHandler::NotifyExit( TExitMode aMode )
{
CEikProcess*  hostProcess = CEikonEnv::Static()->Process();
hostProcess->DestroyDocument(iDoc);
iDoc = NULL;
}

where iDoc is the same document that you've got when you called AddNewDocumentL method.

2.) Maybe there's another way for you to be notified when the embedded application exits. You know, when this happens the embedded app ui losts the focus and your app ui gets it. It happens via HandleForeground method of your app ui. It might be worth do some experiments how this works. The point is that your app ui's HandleForeground method gets called when it gets the focus back from the embedded app ui. So here you have another chance to detect this event.

Cheers,

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Sat, 2004-07-31 14:29
Joined: 2004-07-27
Forum posts: 14
How to invoke an application in embedded mode?
Quote from: tote
2.) Maybe there's another way for you to be notified when the embedded application exits. You know, when this happens the embedded app ui losts the focus and your app ui gets it. It happens via HandleForeground method of your app ui. It might be worth do some experiments how this works. The point is that your app ui's HandleForeground method gets called when it gets the focus back from the embedded app ui. So here you have another chance to detect this event.

Cheers,

tOtE

Hi Tote

First let me thank you for all your great help  Smiley

I have managed to detect the exit of the embedded application in the HandleForegroundEventL and put the code to destroy the document there.

Now i have yet another problem  Huh

My Application is launched by MCE (in embedded mode of course) and like you see inside my application i'm launching another appliction in embedded mode, when that application exits i need to close my application, what i did was to put Exit(); in the HandleForegoundEvenL but when the application i am calling closes i am getting an error in MCE and it closes too. I tried to put User::Exit(0); and it gives me no errors but that way the MCE closes and i don't want it to close  Cry

If for exemple i replace my code to launch the embedded application with something like displaying an information note everything works ok with the Exit(); function.

Am i missing something, maybe some object to destroy?
Mon, 2004-08-02 12:42
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
I have no idea
Hi,

So, when the embedded application is exiting (the application you launched embedded into your app) it crashes? Is it possible that the embedded application is buggy? What is the call stack, anyway?

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Mon, 2004-08-02 16:46
Joined: 2004-07-27
Forum posts: 14
Re: I have no idea
Quote from: tote
Hi,

So, when the embedded application is exiting (the application you launched embedded into your app) it crashes? Is it possible that the embedded application is buggy? What is the call stack, anyway?

tOtE

What crashes is the MCE that called my application because my application is associated with a mime type.
Tue, 2004-08-03 10:56
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
It's still foggy
Hi,

I still don't know which application is crashing, sorry.  Huh

When an embedded application is exiting, its HandleForegroundL method is called with EFalse. After this, the embedding application's HandleForegroundL method will also be called with ETrue. I would like to know if your application's HandleForeground is called or not when it is getting back the control (from the closing embedded app).

Actually we've had a serious problem with issuing an Exit(); at the end of our app's HandleForegroundL method, but it was a really exceptional case: we delayed the Exit with an active object (so that the Exit() method was in fact called inside an AO's RunL method) and when Exit was being executed it crashed the whole application chain. I don't want to bore you with the details, because people usually don't overellaborate their applications like this and thus, you most likely have a different kind of problem.

Cheers,

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Sun, 2005-01-02 21:23
Joined: 2005-01-01
Forum posts: 2
I have a similar problem
Hi,

My embedded application runs for the first time perfectly and when closes, I make sure to delete the view and the document. However, when launches for the second time, it gives a panic CONE 32.

When tracing, it seems happen in the BaseConstructL called from inside the ConstructL of my app UI.

Any clue when this panic happens?

Thanks in advance.

HM.
Wed, 2008-06-25 06:49
Joined: 2008-05-23
Forum posts: 1
Re: How to invoke an application in embedded mode?

In this embedded application case, who is actually responsible for the capabilities of the Embedded app?

Is it the responsibility of Host application to take care of the security for embedded application or does it required to be done by the Embedded application itself?

can some one put notes on this?

  • Login to reply to this topic.