Reputation: 2200
When i try to pass from the main project to library project using intent it works fine but..... when i try to pass from the library project to the main project, it doesn't recognize the class in the main project.
i try to write in my library project this intent :
Intent intent = new Intent(this,com.example.uploadvideo.class);
startActivity(intent);
i add to the manifests of both the main project and library project the two activities that i want to connect.
Upvotes: 0
Views: 3058
Reputation: 1095
The library project does not know about the main project. The prefered solution imo would be to use an action rather than trying to load the class directly in the intent. This will also give you more flexibility if you want to re-use the library.
So the library would do
Intent intent = new Intent("com.example.action_video_upload");
intent.setPackage(mContext.getPackageName()); // only deliver to host app
and the main project would register for that intent in the manifest with
<intent-filter . . . >
<action android:name="com.example.action_video_upload" />
</intent-filter>
More information can be found here: developer.android.com
Upvotes: 5
Reputation: 5472
Library projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the .apk file at build time.
In other words, library project are to be refrenced.
What make sense in calling an intent of your main project from library.
You are actually rendering library project inefficient to handle projects other than your current main project..
Upvotes: 2
Reputation: 132992
start next Activity as:
Intent intent = new Intent(this,com.example.UploadVideo.class);
startActivity(intent);
because currently you are passing wrong Activity name in second parameter to Intent constructor
Upvotes: 1