如何从我的其他应用程序启动我的应用程序?

问题描述:

如何从我的其他应用程序启动我的应用程序? (它们将不被一起打包)如何从我的其他应用程序启动我的应用程序?

--update

清单第二应用的:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.example.helloandroid" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".HelloAndroid" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
       <category android:name="android.intent.category.HOME"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 
     </activity> 

     <activity android:name=".HelloAndroid"> 
      <intent-filter> 
       <action android:name="com.example.helloandroid.HelloAndroid" /> 
      </intent-filter> 
     </activity> 

    </application> 


</manifest> 

我与调用它:

startActivity(new Intent("com.example.helloandroid.HelloAndroid")); 

和它抛出:

07-16 15:11:01.455: ERROR/Desktop(610): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.helloandroid.HelloAndroid } 

Ralated:
How to launch android applications from another application

在第一个应用程序,你将不得不修改AndroidManifest.xml。具体来说,你要自定义action添加到您想从某处启动活动的intent-filter

<activity android:name="FirstApp"> 
    <intent-filter> 
    <action android:name="com.example.foo.bar.YOUR_ACTION" /> 
    </intent-filter> 
</activity> 

然后,在你的第二个应用程序,你使用行动启动活动:

startActivity(new Intent("com.example.foo.bar.YOUR_ACTION")); 

至于您的评论:

看起来像如果我更改默认名称“android.intent.action.MAIN”我不能够运行从Eclipse的应用程序在虚拟设备

请记住,你可以有作为只要你想的许多行动...比如:

<activity android:name="FirstApp"> 
    <intent-filter> 
    <action android:name="com.example.foo.bar.YOUR_ACTION" /> 
    <action android:name="android.intent.action.MAIN" /> 
    </intent-filter> 
</activity> 
+0

看起来像如果我更改默认名称“android.intent.action.MAIN”我不能够运行应用程序来自虚拟设备中的Eclipse。我可以将它作为独立应用程序在手机上运行吗? – 2010-07-16 14:08:44

+0

按照你的说法并且正在丢掷: android.content.ActivityNotFoundException:找不到处理Intent的动作{act = com.example.helloandroid.HelloAndroid}。任何想法可能是错的? (现在我添加了一个新的活动,而不是改变现有的) – 2010-07-16 14:23:15

+0

我编辑了我的答案。此外,我希望看到您的AndroidManifest第一个应用,以及第二个活动的源代码。 – Cristian 2010-07-16 14:45:06

这个问题似乎类似于一个我前面today回答。

如果你只是想开始喜欢你从启动开始吧:

Intent intent = new Intent("android.intent.action.MAIN"); 
intent.setComponent(new ComponentName("PACKAGE NAME", "CLASS")); 
startActivity(intent); 
+0

与上一个答案相同,在最后加上一个问题:“android.content.ActivityNotFoundException:无法找到显式活动类{com.example.helloandroid/HelloAndroid};你是否在你的AndroidManifest.xml中声明了这个活动?” – 2010-07-16 18:06:31