Use third party jar's service in titanium

304 Views Asked by At

I am new in Titanium and making a hybrid application on it. I have a problem like if i make a normal android project and made an activity, a service in that project and made a .jar from it lets say example.jar.

Now i started action with Titanium like i made a MOBILE MODULE PROJECT and add that jar file in lib folder of it and then added it as a library by right click on project-> properties -> addjar. And then made entry in timodule.xml for it like :

<android xmlns:android="http://schemas.android.com/apk/res/android">
    <manifest android:versionCode="1"
    android:versionName="1.1.0"
    android:installLocation="auto">
        <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <uses-permission android:name="android.permission.WAKE_LOCK"/>
        <application>
        <activity android:name="com.example.eaxmpleproject.ExampleActivity">
        </activity>
         <services android:name="com.example.eaxmpleproject.ServiceUtility">
               </services>
        </application>
    </manifest>
</android>

and call start service and activity from mytest2Module.java like this :

    // Methods
@Kroll.method
public String example()
{
    Log.d(TAG, "example called");
    Toast.makeText(getActivity().getApplicationContext(), "opening activity", 1).show();

    Intent intent = new Intent(getActivity(), ExampleActivity.class);
    getActivity().startActivity(intent);

    Intent intent2 = new Intent(getActivity(), ServiceUtility.class);
    getActivity().startService(intent2);


    return "testExample";
}

and then make zip file of it by right click on build.xml and goto runas->AntBuild. After that by taking zip file i made a new MOBILE PROJECT e.g. "newmobileproject" and paste that generated zip file on the root of that newly created "newmobileproject" and call that method from my app.js like this :

var test= require("com.mytest"); test.example();

and made entry in tiapp.xml like this :

<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest android:versionCode="1" android:versionName="1.1.0" android:installLocation="auto"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <application> <activity android:name="com.example.eaxmpleproject.ExampleActivity"> </activity> <services android:name="com.example.eaxmpleproject.ServiceUtility"> </services> </application> </manifest> </android>

So problem is that service is not running after i made all the entries and i don't know why.

1

There are 1 best solutions below

0
On

Are you getting any error? Did you define you module in tiapp.xml?