如何从Android的另一个项目的活动称之为一个项目的活动吗?还有反之亦然? [英] How to call activity of one project from activity of another project in android?Also vice versa?

查看:121
本文介绍了如何从Android的另一个项目的活动称之为一个项目的活动吗?还有反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个集成项目,其中包括集成了两个项目进入one.How我想做的事情是这样的,我有一个共同的项目,这种共同项目的活动应该能打电话通知其他两个项目的活动,按照像一个特定的按钮preSS不同的事件,我etc.How能做到这一点?有没有可能通过的意图?

I am doing an integration project,which involves integrating two projects into one.How I want to do this is,I have a common project,the activity of this common project should be able to call activities of the other two projects,as per different events like a particular button press,etc.How can I do this?Is it possible through intents?

此外,其他两个项目的活动应该能够调用每个other.How做到这一点?

Also,the activities of the other two projects should be able to call each other.How to do this?

推荐答案

您将不得不使用意图过滤器,下面

You will have to use intent filters, Sample code below

    PackageManager packageManager = getPackageManager();

    Intent baseIntent = new Intent(ACTION_PICK_PLUGIN);
    baseIntent.addCategory("matching.catagory");

    List<ResolveInfo> activities = packageManager.queryIntentActivities(baseIntent, PackageManager.GET_RESOLVED_FILTER);

然后使用以下火的意图,

Then fire intent using the following,

Intent baseIntent = new Intent(activities.get(indexOfChild).filter.getAction(0));
baseIntent.addCategory(activities.get(indexOfChild).filter.getCategory(0));     
baseIntent.setComponent(newComponentName(activities.get(indexOfChild).activityInfo.packageName,activities.get(indexOfChild).activityInfo.name));
startActivity(baseIntent);

我希望它能帮助。

I hope it helps..

这篇关于如何从Android的另一个项目的活动称之为一个项目的活动吗?还有反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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