android - Open installed application from application -
i have opencv color blob sample installed on device. have application button. when button pressed, trying call opencv color blob open, have had no success. have tried:
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); } }
then have 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>
how can open application application?
intent launchintent = getpackagemanager().getlaunchintentforpackage("com.package.address"); startactivity(launchintent);