title: what do i have to do to make a imagebutton launch a other app in android
body: <p>I'm creating an app. but now i want it to open a other app with a imagebutton. i searched google for like 5 days there are many awnsers but not the right one.</p>
  
  <p>there are awnsers but not the full explaination.</p>
  
  <p>i found this part </p>
  
  <p><code>Intent intent = new Intent(Intent.ACTION_MAIN);
  intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity"));
  startActivity(intent);
  </code></p>
  
  <p>but where do i have to put this so it works on my imagebutton. and what classes or things do i have to make.</p>
  
  <p>This is my appactifity.java</p>
  
  <pre><code>    package eu.cornholio.rom;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class CornholioROMActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  
  
  }
  </code></pre>
  
  <p>and this is my main.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:gravity="center"
           android:layout_gravity="center"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/cornh" android:contentDescription="@string/cornholio"/&gt;
  
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:text="@string/cornholio" /&gt;
  
      &lt;ImageButton
          android:id="@+id/imageButton1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/cwm" android:clickable="true" android:contentDescription="@string/cmw"/&gt;
  
      &lt;ImageButton
          android:id="@+id/imageButton2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:src="@drawable/jkay"
           android:clickable="true"
            android:contentDescription="@string/jkay"/&gt;
  
  
  &lt;/LinearLayout&gt;            
  </code></pre>
  
  <p>here my code</p>
  
  <pre><code>    package eu.cornholio.rom;
  
  import android.app.Activity;
  import android.content.ComponentName;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.ImageButton;
  
  public class CornholioROMActivity extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          //finding your image button
          ImageButton btn = (ImageButton) findViewByid(R.id.imageButton1);
  
          //setting onClick listener
          btn.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(Intent.ACTION_MAIN);
                  intent.setComponent(new ComponentName("eu.chainfire.cfroot.cwmmanager",
                                         "eu.chainfire.cfroot.cwmmanager.MainActivity"));
                  startActivity(intent); 
              }
          });
  
      }
  
  }
  </code></pre>
  
  <p>greetz drgekko</p>