Whatever is going on has nothing to do with AIDL, since apparently you
aren't even connecting to the service. There are two service examples
in API demos that you can look at for help.
You should always look in the log when getting errors to see if there
are more details printed about what happened.
Btw, the package name "dom.da" is probably not correct for you to
use. You need to use a package name for some domain you have control
over.
On Oct 29, 5:44 am, donm <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I want to share an example Service in Android. The AIDL-file looks
> like this:
>
> package dom.da;
> interface RNS {
> int[] getRandomNumbers(int amount);
>
> }
>
> I created the RNS Interface and implemented it in RemoteService.java:
>
> package dom.da;
>
> import android.app.Service;
> import android.content.Intent;
> import android.os.IBinder;
> import android.os.RemoteException;
>
> public class RemoteService extends Service {
> // implement the interface
> private static final RNS.Stub mBinder = new RNS.Stub(){
> @Override
> public int[] getRandomNumbers(int amount) throws
> RemoteException {
> if (amount < 0)
> return null;
> int[] rc = new int[amount];
> for (;amount > 0; amount--)
> rc[amount] = 0;
> return rc;
> }
> };
> // we only service one innterface, so return it
> @Override
> public IBinder onBind(Intent intent) {
> return mBinder;
> }
>
> }
>
> Now I try to start the service in RNS_Service.java:
> package dom.da;
>
> import android.app.Activity;
> import android.content.ComponentName;
> import android.content.Intent;
> import android.os.Bundle;
> import android.util.Log;
>
> public class RNS_Service extends Activity {
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> Intent i = new Intent();
> i.setClassName("dom.da", "RemoteService");
> ComponentName compName = startService(i);
> if (compName == null)
> {
> Log.e("RNS_Service", "startService() failed!");
> }
> }
>
> }
>
> My AndroidManifest is as follows:
> <manifest
> xmlns:android="http://schemas.android.com/apk/res/android"
> package="dom.da"
> android:versionCode="1"
> android:versionName="1.0.0">
> <application
> android:icon="@drawable/icon"
> android:label="@string/app_name">
> <activity
> android:name=".RNS_Service"
> android:label="@string/app_name">
> <intent-filter>
> <action
>
> android:name="android.intent.action.MAIN"/>
> <category
>
> android:name="android.intent.category.LAUNCHER"/>
> </intent-filter>
> </activity>
> <service android:name="RemoteService" android:exported="true"
> android:enabled="true"/>
> </application>
> </manifest>
>
> This looks like pretty basic stuff, but startService allways returns
> null. Is the way I set the component
> of the service correct as in i.setClassName("dom.da",
> "RemoteService")? Any other errors?
>
> All AIDL examples I find on the net are either too complicated or
> written for an older version
> of the SDK.
>
> Thanks,
> Martin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---