---
title: "How to launch an application with its UID"
author: "svyee"
date: "2009-06-21T12:20:18Z"
tags: []
slug: "how-to-launch-an-application-with-its-uid"
draft: false
lastmod: "2009-06-21T12:21:33Z"
id: 412327
url: "https://svyee.iteye.com/blog/412327"
---

We can launch any application installed on a device with it's [UID](http://wiki.forum.nokia.com/index.php/UID "UID") rather using the name of the application .

- By this way we can prevent the name clashes.
- No need for searching for the full path of the application.

## In mmp file:

```
LIBRARY        apgrfx.lib // for RApaLsSession
LIBRARY        apparc.lib // for CApaCommandLine, TApaAppInfo
```

 

## Source code

```
// System Includes
#include <apgcli.h> // for RApaLsSession
#include <apacmdln.h> // for CApaCommandLine
 
// ...
 
// ----------------------------------------------------------------------------
// CMyUtility::LaunchAppL(const TUid aAppUid)
// Find the application with it's UID and if exists then launch the 
// application to the foreground.
// ----------------------------------------------------------------------------
//
void CMyUtility::LaunchAppL(const TUid aAppUid) const
    {
    RApaLsSession apaLsSession;
    User::LeaveIfError(apaLsSession.Connect());
    CleanupClosePushL(apaLsSession);
 
    TApaAppInfo appInfo;
    TInt retVal = apaLsSession.GetAppInfo(appInfo, aAppUid);
 
    if(retVal == KErrNone)
        {
        CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
        cmdLine->SetExecutableNameL(appInfo.iFullName);
        cmdLine->SetCommandL(EApaCommandRun);
        User::LeaveIfError( apaLsSession.StartApp(*cmdLine) );
 
        CleanupStack::PopAndDestroy(cmdLine);
        }
    else
        {
        // The application not found!
        }
 
    CleanupStack::PopAndDestroy(&apaLsSession);
    }
```