How to trigger the activity of one project from the activity of another project in android? Also the other way around?

I am engaged in an integration project, which includes the integration of two projects into one. How I want to do this, I have a common project, the activity of this common project should be able to trigger the actions of two other projects, depending on various events, for example, on a particular button press, etc. How can i do this? Is this possible with intent?

In addition, the actions of two other projects should be able to challenge each other. How to do it?

+5
source share
3 answers

,

    PackageManager packageManager = getPackageManager();

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

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

, ,

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);

, .

+2

If you want to call the MainActivity of a project from an existing project and vice versa, you can use the PackageManager class

        Intent i;
        PackageManager manager = getPackageManager();
        try {
            i = manager.getLaunchIntentForPackage("Target package");
            if (i == null)
                throw new PackageManager.NameNotFoundException();
            i.addCategory(Intent.ACTION_VIEW );
            startActivity(i);
        } catch (PackageManager.NameNotFoundException e) {

        }
0
source

All Articles