Please help with Android development

by Nerses Zackoyan » Wed, 14 May 2008 11:55:58 GMT

Sponsored Links
 Dear Android Staff,

I have problem with getting event onChange(boolean selfchange) in
ContentObserver when I set getContentResolver().registerContentObserver(
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI ,
true,imageObserver );  and add image file in sdcard using ddms or using
FileOutputStream() .
Also the "media" database in sdcard doesn't refresh data if I add image file
in sdcard. It refreshes only if I restart emulator or if I add using

Here is my code:
import android.content.ContentResolver;
import android.content.Intent;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;

public class PhService extends Service {

        Logger logger=new Logger();
    private Handler handler = new Handler();

    private ImagesObserver imageObserver = null;

    class ImagesObserver extends ContentObserver {
      public ImagesObserver( Handler h ) {
        super( h );

      public void onChange(boolean selfChange) {

    public void show(){
        logger.record("content images", "changed");

    public void onCreate() {
        logger.record("content images", "created");

    protected void onDestroy() {
        // TODO Auto-generated method stub

    protected void onStart(int startId, Bundle arguments) {
        // TODO Auto-generated method stub
        logger.record("content images", "started");

// Set up content observer for our content provider
    private void registerContentObservers() {
     ContentResolver cr = getContentResolver();
      imageObserver = new ImagesObserver( handler );
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI ,
true,imageObserver );


    private void unregisterContentObservers() {
      ContentResolver cr = getContentResolver();

      if( imageObserver != null ) {        // just paranoia
        cr.unregisterContentObserver( imageObserver );
        imageObserver = null;

    public IBinder onBind(Intent intent) {
        //Toast.makeText(this, R.string.no_items,
        // TODO Auto-generated method stub
        return null;




Other Threads

1. AudioHardwareMot

Does anybody know why i loose sound while playing stream?

This is debug when sound lost
D/AudioHardwareMot(  987): AudioMgr:Output 0x11b30 entering standby
D/AudioHardwareMot(  987): AudioMgr:Closing stereo device



2. No emulator window in Eclipse

So I've got a bit of a doozy.  I was playing around with the Motorola
MotoDev IDE, which is kind of a jazzier front-end to Eclipse, and it
asks you on startup if you want the Android emulator to show up in an
IDE window.  I said yes.  That makes the emulator show up in an
Eclipse tab, like the Console, Outline, etc.  After a while it became
apparent that MotoDev wasn't sufficiently different than Eclipse to
make it worth the install.  So I got rid of it.  This is on Mac OS X
with Snow Leopard.  Now when I start Eclipse and run any Android
project, even Hello world, the Console shows the emulator installing
and the APK installing, and the Intent starting.  But no emulator
window.  I found a setting in Eclipse->Preferences->Android->Launch
Settings that said -no-window for the emulator.  MotoDev must have set
that.  That had to be it.  I got rid of it and still no Emulator.  So
I got rid of Eclipse, the SDK, everything and did a full fresh install
of everything.  Still no emulator window.  I can start the emulator
with an AVD from the command line fine and I see it.  But from
Eclipse, nada.  Any ideas?


3. How to install Market app into emulator

4. AOSP Hero with working gstuff

5. Best way to prevent duplicate Activity

6. Interpreting output of test monkey

7. How to detect if the application is in foreground?