1

I have a problem: I want to start an Activity from another application and for that I did the following:

    public void startMyActivity(View view){
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setComponent(new ComponentName("com.package", "com.package.MyActivity"));
    startActivity(intent);
}

But I get the error: Unable to find explicit activity com.package/com.package.MyActivity. Also I declared the MyActivity as activity in the manifest file and I still get the same error. What am I doing wrong? Thanks!

Manifest file of the application A(from which I want to start the activity):

<?xml version="1.0" encoding="utf-8"?>

package="com.example.appA"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" 
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

and this is the Manifest file of the application B(which contains the activity that should be started):

<?xml version="1.0" encoding="utf-8"?>

 package="com.mypackage.package.appB"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="16" />


<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >

    <activity
        android:name="com.package.MyPackage"
        android:label="@string/title" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

ligi
  • 39,001
  • 44
  • 144
  • 244
Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54

1 Answers1

0

Ok so I found my solution. It is a bit frustrating. So.. I tried all the thinks that you guys suggested(I appreciate that) but nothing worked. So my thoughts guided me to use the adb shell to see how it is my application B named and I found out that it is not only com.package, but it's com.mypackage.package(the name mypackage/pakcage are not relevant, only for example purposes). After that I checked the manifest for the application B and saw that the "package" attribute has as value com.mypackage.package. Thank you again!

Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54