Android 从应用程序打开已安装的应用程序
我目前在我的设备上安装了OpenCV Color Blob示例。我现在有一个带按钮的应用程序。当按下此按钮时,我试图调用OpenCV颜色块打开,但没有成功。这就是我尝试过的:Android 从应用程序打开已安装的应用程序,android,opencv,Android,Opencv,我目前在我的设备上安装了OpenCV Color Blob示例。我现在有一个带按钮的应用程序。当按下此按钮时,我试图调用OpenCV颜色块打开,但没有成功。这就是我尝试过的: public class MainActivity extends Activity { public String packge_name = "org.opencv.samples.colorblobdetect"; public String class_name = "ColorBlobDetectionActi
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>
如何从我的应用程序打开应用程序?Intent launchIntent=getPackageManager().getLaunchIntentForPackage(“com.package.address”);startActivity(launchIntent) 你能再解释一下你的问题吗?嗨,酸奶,我当然能。我的设备上安装了一个名为Open CV Color Blob的应用程序。我现在正在编写一个新的应用程序,当您单击新应用程序中的一个按钮时,这将启动Open CV Color Blob。我试图用Intent来做,但没有用。Intent launchIntent=getPackageManager().getLaunchIntentForPackage(“com.package.address”);startActivity(launchIntent);为了实现此目的,您必须知道应用程序的程序包名称,否则它将无法工作。如果有必要,根据调试信息在清单中添加一些权限,我现在有以下权限:public void launchCall(){//TODO自动生成的方法stub Intent launchIntent=getPackageManager().getLaunchIntentForPackage(“org.opencv.samples.colorbobdetect”);startActivity(launchIntent);}但是,应用程序强制关闭:(