从另一个应用程序的Andr​​oid发射活动 [英] Launch Activity from another Application Android

查看:149
本文介绍了从另一个应用程序的Andr​​oid发射活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application">Android从另一个应用程序启动应用程序

Possible Duplicate:
Android Launch an application from another application

我有一个问题,它是下列之一:

I am having a problem and it is the following one:

我有两个应用程序,我想用另外一个启动活动之一,从一个应用程序......我要举一个例子:

I have two applications, and I want to launch one of the activities from one app by the other one......I am gonna give an example:

第一个应用程序包:

es.wul4.android.app1

"es.wul4.android.app1"

第二个应用程序包:

es.wul4.android.app2

"es.wul4.android.app2"

我要的是推出的类名为Identificar从APP1

What I want is to launch the activity whose class is called "Identificar" from the app1

这个活动不是主要的一个。我试图通过doind是:

This activity is NOT the main one. I tried by doind that:

Intent intent = getPackageManager().getLaunchIntentForPackage("es.wul4.app2.Identificar");
startActivity(intent);

不过,我所得到的这样做是什么,它​​告诉我,该应用程序doesn't存在。

But what i get doing that is nothing, it tells me that the app doesn´t exists.

如果我尝试这样做:

getPackageManager().getLaunchIntentForPackage("es.wul4.app2");
startActivity(intent);

和它推出一个活动,但主要是........

And it launch one activity, but the main one........

我怎么能推出这个特别的活动里面包es.wul4.app2.Identificar??

How can I launch this particular Activity inside the package "es.wul4.app2.Identificar"??

ü非常感谢。

推荐答案

您需要使用的意图过滤器是什么。假设要推出的活动是在包 launch.me 。在这个应用中体现的所有活动(主或其他方式)将由&LT被decalred;活性GT; 标签
假设你要启动的活动是类文件 Launchme 里面。那么你的表现的一部分将是这样的:

What you need to use are intent-filters. Assume the activity to be launched is in the package launch.me. Inside this applications manifest all the activities (main or otherwise) will be decalred by the <activity> tag.
Assuming the activity you want to launch is inside the class file Launchme. Then a portion of your manifest will be something like:

<activity android:name="launch.me.Launchme"
              android:label="@string/app_name">
<intent-filter>
            <action android:name="launch.me.action.LAUNCH_IT"/>
            <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>  

现在从要推出上述活动中使用的行为:(注:本次活动可以在任何包中任何地方,你必须确保两个,主叫和被叫套餐都可以在设备上)

Now in the activity from where you want to launch the above activity use:(Note: This activity can be in any package anywhere. You have to make sure that both, the calling and the called packages are available on the device)

Intent i=new Intent();
i.setAction("launch.me.action.LAUNCH_IT");
startActivityForResult(i,0);

您可以采用其他方法来启动意图以外 startActivityForResult ,这就是高达你。

You can use other methods for starting the intent other than startActivityForResult, thats upto you.

这篇关于从另一个应用程序的Andr​​oid发射活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆