Local Service - How to actually invoke methods

by Paul Townsend » Tue, 10 Nov 2009 02:08:14 GMT


Sponsored Links
 Hi I have looked at the Api's demo for local service but it doesn't
show how to invoke methods on the service or activity. I got a service
that will start and stop a timer but it also laps so I want to send
the lap times back to the activity so it can be displayed in a custom
view graph. This is just a small part of the program I to write hence
the reason its in a service atm, I just want to understand how to call
methods from service to activity and vice versa.

--



Other Threads

1. DroidDrop - Remote Logging with source code

Drop.io provides private file storage and sharing in "drops."

DroidDrop Remote Logging provides the ability to log data from your
applications to a drop on drop.io.
Watch the 2 minute YouTube demo here: http://www.youtube.com/watch?v=OWwfp1cQ8WA

Source and how-to info is on GitHub.
The jar file for remote logging adds 16K to your apk.
http://github.com/CarmenD/DroidDrop--Remote-Logging

My goal in the remote logging release was to:
- deliver something useful to Android developers
- get some usage and feedback
- make at least a limited version of the drop.io client code available
- get something out that required very limited testing!

I'll be blogging and writing more about this.

Carmen
--
Carmen
http://www.twitter.com/CarmenDelessio
http://www.talkingandroid.com
http://www.facebook.com/BFFPhoto
http://www.twitter.com/DroidDrop


-- 

2. problem reading from the Camera

Hello all ! My app will show the current image from the camera and
bellow the binary version of the image black and white, and will write
some different algorithms make the binary image.

I'm having and error when I try to read from the camera:
11-05 02:27:15.357: ERROR/camera(736): not able to link with the
camera

and after that in my app I have the following
11-05 02:27:15.357: ERROR/camera(736): java.lang.NullPointerException
11-05 02:27:15.357: ERROR/camera(736):     at
com.athanazio.android.camerabinaria.Main.onCreate(Main.java:29)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
11-05 02:27:15.357: ERROR/camera(736):     at
android.os.Handler.dispatchMessage(Handler.java:99)
11-05 02:27:15.357: ERROR/camera(736):     at android.os.Looper.loop
(Looper.java:123)
11-05 02:27:15.357: ERROR/camera(736):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
11-05 02:27:15.357: ERROR/camera(736):     at
java.lang.reflect.Method.invokeNative(Native Method)
11-05 02:27:15.357: ERROR/camera(736):     at
java.lang.reflect.Method.invoke(Method.java:521)
11-05 02:27:15.357: ERROR/camera(736):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
11-05 02:27:15.357: ERROR/camera(736):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
11-05 02:27:15.357: ERROR/camera(736):     at
dalvik.system.NativeStart.main(Native Method)

I noticed this in the LogCat before the problem that I had
11-05 02:27:14.937: ERROR/MediaPlayer(554): Unable to to create media
player
11-05 02:27:14.947: ERROR/CameraService(554): Failed to load
CameraService sounds.
11-05 02:27:14.957: ERROR/MediaPlayer(554): Unable to to create media
player
11-05 02:27:14.977: ERROR/CameraService(554): Failed to load
CameraService sounds.

this is my current code
package com.athanazio.android.camerabinaria;

import java.io.IOException;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PreviewCallback;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;

public class Main extends Activity {

        Camera camera;

        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                try {
                        camera = Camera.open();
                        SurfaceView original = (SurfaceView) 
findViewById(R.id.original);
                        camera.setPreviewDisplay(original.getHolder());
                        Parameters cameraParameters = camera.getParameters();
                        cameraParameters.setPreviewFormat(PixelFormat.RGB_888);

                        camera.setPreviewCallback(new PreviewCallback() {
                                SurfaceView changed = (SurfaceView) 
findViewById(R.id.changed);

                                public void onPreviewFrame(byte[] _data, Camera 
_camera) {
                                        Bitmap bitmap = 
BitmapFactory.decodeByteArray(_data, 0,
                                                        _data.length);

                                        Canvas canvas = new Canvas();
                                        canvas.drawBitmap(bitmap, 0, 0, null);
                                        changed.draw(canvas);
                                }
                        });

                        camera.startPreview();

                } catch (Exception e) {
                        showMessage("error", "not able to use the camera");
                        Log.e("camera", "not able to link with the camera", e);
                }

                setContentView(R.layout.main);
        }


        void showMessage(CharSequence title, CharSequence message){
                Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(title);
                builder.setMessage(message);
                builder.show();
        }

        protected void onDestroy() {
                super.onDestroy();
                if (camera != null) {
                        camera.stopPreview();
                        camera.release();
                }
        }
}

any toughts ?

-- 

3. Application is not installed on your phone ERROR while launching the application?

4. Where do I write my changelog?

5. about the signature permission - what happen if the declaring app is uninstalle

6. Possible bug with Intents and PendingIntents on Android 2.0 AVD

7. error when starting Android project in Eclipse