0

I am trying to create a new application ("My New App") from the source of another application that I have ("My Previous App").

In order to do it, I've created a new flavor, changed the app name and new icons for the new flavor, and everything goes ok.

But I've encountered that I can't launch (at least) one activity.

The activity is declared in a library included as a module and is defined in this way in the library manifest.xml:

<activity android:name="com.my.company.core.views.download.VersionActivity"
            android:label="@string/app_name"
            android:exported="false"
            android:screenOrientation="portrait" />

And I am trying to launch that activity in the following way:

Intent intent = new Intent(CurrentActivity.this, VersionActivity.class);
startActivity(intent);

If I have only one app, for example "My New App" installed in the terminal it works perfect. But if I have installed both apps "My New App" and "My Previous App" when I try to launch the activity as described Android says "No application can perform this action".

Can't I share code between apps? Is there a problem with the declaration of the activity in thee manifest? By the way, I've tried with exported="true" but it didn't work anyway.

Thanks in advance.

iVela
  • 1,160
  • 1
  • 19
  • 40

1 Answers1

0

You can specify that your current app should handle the intent using setPackage.

Intent intent = new Intent();
intent.setAction("com.my.company.core.views.download.VersionActivity");
intent.setPackage(context.getPackageName());
startActivity(intent);
Chrisvin Jem
  • 3,940
  • 1
  • 8
  • 24
  • Thanks for your comment. I've tried as you said and It keeps saying "No application can perform this action". – iVela Jul 18 '19 at 17:34
  • I've updated my answer to try using an implicit intent. You really shouldn't need to though, android usually takes care of all this stuff properly. – Chrisvin Jem Jul 18 '19 at 17:41