0

I'm having a really odd problem that seems very unrelated. I'm trying to use intent filters to open an activity (as recc from other questions on SO) in my main application from an activity in a library I created. In the library activity I create/call the intent like so:

Intent i = new Intent("com.application.mainapplication.tagDetailActivity");
// sending data to new activity
i.putExtra("sub_category", subCats[(int)id]); //Serializable data
i.putExtra("Category", category.name);
startActivity(i);

If I comment the two i.putExtra's I get the following error:

Could not find Library.apk!

In my manifest for the main application I have:

<activity android:name=".tagDetailActivity">
    <intent-filter >
        <action android:name="com.tagsforlikes.tagsforlikes.tagDetailActivity" />
    </intent-filter>
</activity>

I'm not really sure why putExtra's are causing this error. Am I creating the intent correctly? It doesn't look much different than starting a normal intent (read: not intentfilter) and I'm worried I'm creating it wrong.

UPDATE

I think there is some confusion. The activity I am trying to call is not the main activity of the main application. So for the application I have a Free/Pro version that both reference a library. In the free/pro version, the main activity creates an activity in the library which in turn must call an activity in the free/pro version again.

Zaheer
  • 2,548
  • 5
  • 24
  • 33
  • have you added your libs/yourjar.jar file in build path? – Pratik Aug 21 '12 at 07:28
  • You sure that's all the error you get? 1 line sounds inconceivable. Edit: Are you working in eclipse? – Anders Metnik Aug 21 '12 at 07:29
  • @Pratik No, I actually removed the build path after having it previously as per this suggestion: http://stackoverflow.com/questions/6337673/could-not-find-library-apk – Zaheer Aug 21 '12 at 07:35
  • @AndersMetnik Yes that is the error I get in console. The error isn't that long because the application does not even launch so logcat doesn't show anything. – Zaheer Aug 21 '12 at 07:36
  • Basicly is your library .apk installed? If not, either have it's source code in another project, and export it together with your current project. – Anders Metnik Aug 21 '12 at 08:10
  • It was installing before - if I literally comment out those two putExtra's above the app will compile and run on my phone. But when is time to call the activity in the actual app from the library using intentfilter, the app crashes saying: ActivityNotFoundException: No Activity found to handle Intent { act=com.application.mainapplication.tagDetailActivity (has extras) } – Zaheer Aug 21 '12 at 08:13
  • rightclick project(not library), properties, Java Build Path, Order And Export. Is your library here? if, make sure that it is checked. If not, make sure that under Libraries it is added. – Anders Metnik Aug 21 '12 at 08:31
  • Thanks for response. My library wasn't in Order and Export, added it to Libraries - tried it checked/unchecked/at top/bottom of list. Oddly when I change the settings, the app runs the first time and instead of opening the activity I want it open up the Messages/SMS app. The second time+ I run it, goes back to same error. At this point I'm considering shelving the whole library and just making two separate but very similar codebase apps. :( – Zaheer Aug 21 '12 at 08:42

4 Answers4

1
 <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
 </intent-filter>
shassss
  • 321
  • 1
  • 13
  • Doesn't work. I get ActivityNotFoundException: No Activity found to handle Intent { act=com.application.mainapplication.tagDetailActivity (has extras) } – Zaheer Aug 21 '12 at 07:21
0
<activity android:name=".--your class name--" android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
Dipak Keshariya
  • 21,618
  • 18
  • 74
  • 127
raghav chopra
  • 797
  • 3
  • 8
  • 25
0

take a look this answer

Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(ComponentName.unflattenFromString("com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks"));
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);

for this your another activity should be installed.

see more related post

Android, How can I use external APK in my application?

Open another application from your own (intent)

Community
  • 1
  • 1
Pratik
  • 30,114
  • 17
  • 82
  • 154
  • Unfortunately still got same 'Could not find library.apk' error. I'll read into the other answers and keep the post updated if I make any progress. – Zaheer Aug 21 '12 at 07:54
0

Sounds like it isn't installed on your phone at all:

Rightclick project(not library), properties, Java Build Path, Order And Export. Is your library here? if, make sure that it is checked. If not, make sure that under Libraries it is added.

Anders Metnik
  • 5,518
  • 7
  • 32
  • 69