Project dependency: reusing code and resources from another Android project

by Mark Murphy » Thu, 10 Dec 2009 22:29:37 GMT


Sponsored Links
 > According to

Which gets you little, since you cannot force the user to install A.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android App Developer Books:  http://commonsware.com/books.html 


--



Project dependency: reusing code and resources from another Android project

by Mark Murphy » Thu, 10 Dec 2009 22:49:37 GMT


 >> Which gets you little, since you cannot force the user to install A.

Which will irritate your users.


Which will irritate your users.

Hence, I stand by my assessment that, while there are ways for B to access
A's resources at runtime, in general, that's not a viable reuse model. You
are trading a trivial development-time inconvenience for a crappy user
experience, which won't be a good trade in most cases.

Your development-time symlink approach is about as good as it gets today,
at least for solo developers.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android App Developer Books:  http://commonsware.com/books.html 


--


Sponsored Links


Project dependency: reusing code and resources from another Android project

by Mark Murphy » Fri, 11 Dec 2009 03:31:14 GMT


 > Well, in this case you have to go java way:

Moreover, that'll just give you a stream. It won't work for anything that
needs a resource ID, won't support resource sets (e.g., i18n, landscape
vs. portrait), and so on. Unfortunately, Java's "resources" and Android's
"resources" share a name, a very high level concept, and nothing else.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android App Developer Books:  http://commonsware.com/books.html 


--



Other Threads

1. Join the Android Developer Group on Linkedin!

Join over 1,500 Android professionals to share, learn, and network.
The resource for connecting professionals with experience in
developing, selling, marketing, managing, supporting and/or creating
new business around the Android platform.

You may join this group by going to the following link:
http://www.linkedin.com/e/gis/86481/4DA362688A87

Regards,
-Austin Teames
Group Manager

--~--~---------~--~----~------------~-------~--~----~

2. Does Camera API really works ?

I tried google's camera API sample code. I found there are 2 problems:
1> It only can take picture in Landscape orientation
2> After click the space "key", the application crashes. WOw:)

XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
    android:orientation="vertical">
    <SurfaceView android:id="@+id/surface"
        android:layout_width="fill_parent"
android:layout_height="10dip"
        android:layout_weight="1">
    </SurfaceView>
</LinearLayout>
Java code:
/**
 * Copyright (c) 2007, Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
 * See the License for the specific language governing permissions
and
 * limitations under the License.
 */

package com.android.cameraapitest;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.KeyEvent;
import android.hardware.Camera;

import android.util.Log;

public class CameraApiTest extends Activity implements
SurfaceHolder.Callback
{
    private static final String TAG = "CameraApiTest";
    Camera mCamera;
    boolean mPreviewRunning = false;

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

        Log.e(TAG, "onCreate");

        getWindow().setFormat(PixelFormat.TRANSLUCENT);

        setContentView(R.layout.camera_api_test);
        mSurfaceView = (SurfaceView)findViewById(R.id.surface);

        mSurfaceHolder = mSurfaceView.getHolder();
        mSurfaceHolder.addCallback(this);
        mSurfaceHolder.setType
(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    public boolean onCreateOptionsMenu(android.view.Menu menu) {
        MenuItem item = menu.add(0, 0, 0, "goto gallery");
        item.setOnMenuItemClickListener(new
MenuItem.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
                Uri target = Uri.parse("content://media/external/
images/media");
                Intent intent = new Intent(Intent.ACTION_VIEW,
target);
                startActivity(intent);
                return true;
            }
        });
        return true;
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState)
    {
        super.onRestoreInstanceState(savedInstanceState);
    }

    Camera.PictureCallback mPictureCallback = new
Camera.PictureCallback() {
        public void onPictureTaken(byte[] data, Camera c) {
            Log.e(TAG, "PICTURE CALLBACK: data.length = " +
data.length);
            mCamera.startPreview();
        }
    };

    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return super.onKeyDown(keyCode, event);
        }

        if (keyCode == KeyEvent.KEYCODE_SPACE) {
            mCamera.takePicture(null, mPictureCallback);
            return true;
        }

        return false;
    }

    protected void onResume()
    {
        Log.e(TAG, "onResume");
        super.onResume();
    }

    protected void onSaveInstanceState(Bundle outState)
    {
        super.onSaveInstanceState(outState);
    }

    protected void onStop()
    {
        Log.e(TAG, "onStop");
        super.onStop();
    }

    public void surfaceCreated(SurfaceHolder holder)
    {
        Log.e(TAG, "surfaceCreated");
        mCamera = Camera.open();
        //mCamera.startPreview();
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int
w, int h)
    {
        Log.e(TAG, "surfaceChanged");

        // XXX stopPreview() will crash if preview is not running
        if (mPreviewRunning) {
            mCamera.stopPreview();
        }

        Camera.Parameters p = mCamera.getParameters();
        p.setPreviewSize(w, h);
        mCamera.setParameters(p);
        mCamera.setPreviewDisplay(holder);
        mCamera.startPreview();
        mPreviewRunning = true;
    }

    public void surfaceDestroyed(SurfaceHolder holder)
    {
        Log.e(TAG, "surfaceDestroyed");
        mCamera.stopPreview();
        mPreviewRunning = false;
        mCamera.release();
    }

    private SurfaceView mSurfaceView;
    private SurfaceHolder mSurfaceHolder;
}


--~--~---------~--~----~------------~-------~--~----~

3. XMLHttpRequest

4. List in Gallery

5. Slow searching in large sqlite database ?

6. Dialog in wrong orientation

7. HTC Hero has multi-touch. SDK support?