Hello Everyone,

I have created a small util which is a service, I would like to reuse
this util in my future projects.

I have exported /src /gen folders to jar. I have skipped, /res folder
and AndroidManifest.xml files.

I have tried including this in my new app activity and reuse the
service. But I get the error message "Unable to start service Intent
".

I have enclosed the Manifest XML and outline of my project.

My Questions are:

1. Have I exported the right files to JAR?
2. Any other information needs to be added in my AndroidManifest.XML
(in App, not in Service) to reuse the service provided by the JAR.

Can someone help me to point out where have I gone wrong?

Thanks in Advance,
Vinay


----------------- Service manifest.xml  -------------------------

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
package="com.ere.SDKUtil"  android:versionCode="1"
android:versionName="1.0">
    <application android:debuggable="true">
            <service android:name="SDKUtil"></service>
                <receiver android:name="BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:enabled="true"></receiver>
</application>
        <uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="... "></uses-permission>
</manifest>

----------------- SDKUtil.java  -------------------------
package com.ere.SDKUtil;

<All imports are here>
public class SDKUtil extends Service {
        public IBinder onBind(Intent intent) {
                return null;
        }

        public void onCreate() {
                  super.onCreate();
                  // init the service here
                  try {
                     _startService();
                  } catch (Exception e) {
                      Log.d("Service", "Start Service Failed : "+e.toString() );
                }
        }

        public void onDestroy() {
                super.onDestroy();
                _shutdownService();
        }
}

/*--------------- Second App, which uses the Jar file created as
mentioned above -------------*/

------------------------------------
AndroidManifest.xml-------------------------------------
 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
package="com.ere.SDKSampleApp"
 android:versionCode="1" android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name" android:debuggable="true">
        <activity android:name=".SDKSampleApp" android:label="@string/
app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>

------------------------------------------- SDKSampleApp.java
-------------------------------------
package com.ere.SDKSampleApp;

import com.ere.SDKUtil.SDKUtil;

public class SDKSampleApp extends Activity {
        TextView outputView ;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        outputView = (TextView) findViewById(R.id.output) ;
        try {
                   Intent intent = new Intent (this, SDKUtil.class) ;
                   startService(intent) ;
                   outputView.setText(R.string.header +"\n\n Please
Wait...! \n\n Getting info... ") ;
        } catch (Exception e) {
                outputView.setText(R.string.header + "\n\nError :" +
e.toString()) ;
        }
    }
}

----------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to