Shalini
Shalini

Reputation: 1733

Calling Activity within jar file

I want to use to start an activity from jar file with my application. In my jar file i use

Intent intent=new Intent(cl,com.jar.Adview.class);
            cl.startActivityForResult(intent,0);

Where, cl is Activity of my application. Adview.class is in my jar package called com.popupjar.But it throws null pointer exception. How to do this. Please give me a solution.

Note: The intent will be in a method. When i call the method in my apllication the intent activity want to be start.

Upvotes: 2

Views: 1622

Answers (3)

Normandooak
Normandooak

Reputation: 46

Android sdk contains dx tool to convert Java bytecode to Dalvik bytecode.
First your jar file must contain Dalvik bytecode, to do this you need to open the terminal or cmd and enter:

dx --dex --output=classes.dex nameofyourjar.jar
aapt add nameofyourjar.jar classes.dex

Pay attention for some restrictions, you will know more about them when you generate your .jar

Upvotes: 0

Rajdeep Dua
Rajdeep Dua

Reputation: 11230

Looks like cl is null in the code

Upvotes: 0

Kannan Suresh
Kannan Suresh

Reputation: 4580

Check this: Integrate zxing barcode scanner into your Android app natively using Eclipse

Check the step 4(Include ZXing Android into your project). You can see how the activity for scan (which is in the jar) is being called.

Hope this would help.

Upvotes: 1

Related Questions