我如何从我的其他应用程序启动我的应用程序? (他们不会一起打包)
- 更新
第二个应用程序的清单:
<?XML版本=1.0编码=UTF-8&GT?;<清单的xmlns:机器人=http://schemas.android.com/apk/res/android 包=com.example.helloandroid 安卓版code =1 机器人:=的versionName1.0> <应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME> <活动机器人:名字=HelloAndroid 机器人:标签=@字符串/ APP_NAME> &所述;意图滤光器> <作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/> <类机器人:名字=android.intent.category.HOME/> <类机器人:名字=android.intent.category.DEFAULT/> &所述; /意图滤光器> < /活性GT; <活动机器人:名字=HelloAndroid> &所述;意图滤光器> <作用机器人:名字=com.example.helloandroid.HelloAndroid/> &所述; /意图滤光器> < /活性GT; < /用途>< /清单>
我称之为:
startActivity(新意图(com.example.helloandroid.HelloAndroid));
和它抛出:
15 07-16:11:01.455:ERROR /桌面(610):android.content.ActivityNotFoundException:无活动来处理意图行事{= com.example.helloandroid.HelloAndroid }
Ralated:结果http://stackoverflow.com/questions/1605074/how-to-launch-android-applications-from-another-application
解决方案在第一个应用程序,你将不得不修改的AndroidManifest.xml
。具体来说,你要添加自定义动作
到您希望从启动意图过滤器
活动的的地方的:
<活动机器人:名字=FirstApp> &所述;意图滤光器> <作用机器人:名字=com.example.foo.bar.YOUR_ACTION/> &所述; /意图滤光器>< /活性GT;
然后,在你的第二个应用程序,你使用行动启动活动:
startActivity(新意图(com.example.foo.bar.YOUR_ACTION));
至于您的意见:
看起来像如果我更改默认名称android.intent.action.MAIN我不能够运行从Eclipse的应用程序在虚拟设备
请记住,只要你想,你可以有很多的动作......比如:
<活动机器人:名字=FirstApp> &所述;意图滤光器> <作用机器人:名字=com.example.foo.bar.YOUR_ACTION/> <作用机器人:名字=android.intent.action.MAIN/> &所述; /意图滤光器>< /活性GT;
How do I start my app from my other app? (they will not be package together)
--update
Manifest of the second app:
<?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>
I calling it with:
startActivity(new Intent("com.example.helloandroid.HelloAndroid"));
and it throws:
07-16 15:11:01.455: ERROR/Desktop(610): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.helloandroid.HelloAndroid }
Ralated: http://stackoverflow.com/questions/1605074/how-to-launch-android-applications-from-another-application
解决方案In the first app, you will have to modify the AndroidManifest.xml
. Specifically, you are going to add a custom action
into the intent-filter
of the activity that you want to launch from somewhere:
<activity android:name="FirstApp">
<intent-filter>
<action android:name="com.example.foo.bar.YOUR_ACTION" />
</intent-filter>
</activity>
Then, in your second app you use that action to start the activity:
startActivity(new Intent("com.example.foo.bar.YOUR_ACTION"));
With regards to your comments:
Looks like if I change the default name "android.intent.action.MAIN" I'm not able to run the app from the Eclipse in the Virtual Device
Keep in mind you can have as many actions as you want... for instance:
<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>