Check list of apps instaleld on device and find the package name of my app?
<p>I am trying to find the package name of my application by providing the app name. Below approach is taking very long time on Droid3. How can I optimize this or am I missing something?</p>

<pre><code> String                     sPackageName        = null;

   PackageManager           pm                  = m_Context.getPackageManager();

 //get a list of installed apps.
  List&lt;ApplicationInfo&gt;     packages            = pm.getInstalledApplications(PackageManager.GET_META_DATA);

  ApplicationInfo   ap  = new ApplicationInfo();
  ap.loadLabel(pm);



   for (ApplicationInfo packageInfo : packages) {

        String          sApp                = packageInfo.loadLabel( pm ).toString();

        //Log.d(TAG, "Installed AppName = " + appName + "  ,package :" + packageInfo.packageName );
        //Log.d(TAG,   "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName)); 

        if( sApp.compareTo( sAppName ) == 0 ){

            sPackageName    = packageInfo.packageName;
            break;
        }

   }// the getLaunchIntentForPackage  

   return sPackageName;
</code></pre>

<p>Thanks,
DK</p>
