I have created two projects. The first one, extracts information of handset and shows on the screen. I have .apk file of this project (for example test.apk).
Then I created second project. This one has a button on the screen and I want when I click the button, first project runs (shows information of handset). I have added test.apk into this project by right clicking on root of project>Build Path>Configure Build Path>Add External JARs>test.apk
Then in the code, I called this by using intent. this is my code:
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("com.in.test.MainActivity");
startActivity(intent);
}
});
however, when I run the application, according to logcat, I see following error: 11-18 10:09:28.933: E/AndroidRuntime(2237): Uncaught handler: thread main exiting due to uncaught exception 11-18 10:09:29.022: E/AndroidRuntime(2237): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.in.test.MainActivity } 11-18 10:09:29.022: E/AndroidRuntime(2237): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1484) . . .
What and where is my problem? Thanks
update:
In the manifest file I added this line inside of application
element:
<activity
android:name="com.in.test.MainActivity" />
but the result is still the same. I'll try to follow your suggestion (using intent filter).
You can't do this from Eclipse. test.apk needs to be installed, and it needs to export the activity you need and have an intent filter for it. Something like:
If you have access to test.apk's source, modify it. If not, you can only use the activities/intents it exports.
To start an activity with an explicit intent like you are doing (by using the activity class in the constructor), the activity must be declared in the manifest for your app and must be complied into your app. You cannot use a separate apk file for that.
The way to do what you want is to declare an intent filter for the activity in test.apk and to launch it using an appropriate intent. See the guide topic Intents and Intent Filters and the documentation for the Intent class for more information about how to do this.