Archived:Launching MIDlets programmatically on S60 3rd Edition
Article Metadata
Compatibility
Article
Contents |
Overview
Launching MIDlets programmatically on S60 3rd Edition.
Description
When a MIDlet is installed on an S60 3rd Edition device, it will be assigned a MIDlet-Suite UID and a MIDlet-specific UID, both of which are generated during installation. Files for the MIDlet will be placed in \private\102033E6\MIDlets\[MIDlet Suite UID]
Since the MIDlet files are located in a private directory, it is not possible to access them directly. However, an entry in the list of installed applications is also created for a MIDlet. This list is maintained by the application architecture server, and can be read by using the methods from the RApaLsSession class.
Each MIDlet entry in the list will have a ".fakeapp" extension in the application executable name. This information can be used when scanning through the list to separate MIDlets from native applications. In order to launch a MIDlet from native code, its MIDlet-specific UID must be found.
Solution
The following code snippet shows how to search for all installed MIDlets:
TApaAppInfo appInfo;
RApaLsSession apaSession;
User::LeaveIfError( apaSession.Connect() );
CleanupClosePushL( apaSession );
User::LeaveIfError( apaSession.GetAllApps() );
while ( apaSession.GetNextApp( appInfo ) == KErrNone )
{
if(appInfo.iFullName.Right(8).Compare(_L(".fakeapp") == 0)
{// Caption of the MIDlet can be read from appInfo.iCaption
// When the MIDlet to be launch is found, store its UID
// (appInfo.iUid) for later use.
}
}
CleanupStack::PopAndDestroy();
// close apaSession
Launching the MIDlet
Once the UID of the MIDlet is known, it can be launched as follows:
TThreadId threadId;
apaSession.StartDocument(_L(""), iMidletUID, threadId);
An empty descriptor can be passed as the first parameter (document name).
If the launching application wishes to monitor the MIDlet and receive a notification when it is closed, it can be done by deriving from CActive and calling RThread::Logon():
TInt ret = iLaunchThread.Open(threadId); // iLaunchThread is of type RThread<
if(ret == KErrNone)
{
iLaunchThread.Logon(iStatus);
SetActive();
}
Launching a MIDlet at device startup
S60 does not provide any mechanism for launching MIDlets at device startup. However, using the code above, it is possible to write a minimal Symbian application that finds and launches the MIDlet. This launcher application can be then added to the device startup list.
Note that applications on the startup list must be signed against a trusted certificate.
For more information, see documentation on Startup List Management API on SDK Help.


Thread returned for .fakeapp is destroyed almost immediately (both for StartApp and StartDocument), sometimes it even cannot be found and opened :) Looks like midlet is launched through some proxy application that runs midlet and quits, shame is it is it's thread that is returned.
Would anybody say it's true if it's true?