title: how to launch an app from another app in android
body: <p>I am developing an app in which i want to launch any application installed on my device. I have tried the following code.</p>
  
  <pre><code>Button bClock = (Button) findViewById(R.id.button1);
  String app="com.whatsapp";
  bClock.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      Intent i = new Intent(Intent.ACTION_MAIN);
      PackageManager managerclock = getPackageManager();
      i = managerclock.getLaunchIntentForPackage(app);
      i.addCategory(Intent.CATEGORY_LAUNCHER);
      startActivity(i);
    }
  });
  </code></pre>
  
  <p>It shows error:</p>
  
  <blockquote>
    <p>Cannot refer to a non-final variable app inside an inner class defined
    in a different method</p>
  </blockquote>
  
  <p>But if I directly use "com.whatsapp" instead of storing in String, it is working. Help me to solve this issue</p>