从应用程序打开安装的应用

时间:2015-04-09 20:13:50

标签: android opencv

我目前在设备上安装了OpenCV Color Blob Sample。我现在有一个带按钮的应用程序。按下此按钮时,我试图打开OpenCV Color Blob,但我没有成功。这就是我的尝试:

public class MainActivity extends Activity {

public String packge_name = "org.opencv.samples.colorblobdetect";
public String class_name = "ColorBlobDetectionActivity";

Button bt;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bt = (Button) findViewById(R.id.button1);
    }

public void launchCall() {
    // TODO Auto-generated method stub
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(new ComponentName(packge_name, class_name));
    startActivity(intent);
    }   
      }

然后这就是我的XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

        <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:onClick="launchCall"
        android:text="Call Other App" />

       </RelativeLayout>

如何从我的应用程序中打开应用程序?

1 个答案:

答案 0 :(得分:0)

Intent launchIntent = getPackageManager()。getLaunchIntentForPackage(&#34; com.package.address&#34;); startActivity(launchIntent);