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
android.provider.MediaStore.Images.Media.insertImage().

Here is my code:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import android.app.Service;
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) {
          show();
      }
    }

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

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

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

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

// Set up content observer for our content provider
    private void registerContentObservers() {
     ContentResolver cr = getContentResolver();
      imageObserver = new ImagesObserver( handler );
      cr.registerContentObserver(
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;
      }
    }



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

Thanks,

Nerses.

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



Other Threads

1. APN Problem

Hi I am trying to use my ISP network but unfortunately I am unable to
configure the APN.

How to add a new APN manually?

Actually I am getting this error message when I use the android interface:

E/TelephonyProvider( 2116): Failed setting numeric 'null' to the
current operator
D/MobileDataStateTracker( 2049): default Received state= DISCONNECTED,
old= DISCONNECTED, reason= apnChanged, apnTypeList= default

The APN configuration is:

APN Name: claro
MMC: 724
MCC; 05
User: claro
Password: claro

I've found 3 files with APN configuration:

/data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml
/system/etc/apns-conf.xml
/data/data/com.android.providers.telephony/databases/telephony.db


How to proceed?


Thanks very much.



-- 
Hamilton Vera
int Administrator (char Network[],char ComputationalSystems[])
http://hvera.wordpress.com

-- 

2. ViewFlipper with just one View

Hi!
I'm planning on creating an app with a news page with image, title,
content, etc.
The "flip" animations used in most ViewFlipper applications are great
but have one problem: only work with a ViewFlipper with a determinate
number of view (in my case, I don't know how many news there are).

The only solution I found is to duplicate the View, prepare the
contents off-screen then call ViewFlipper's showNext() when the "Next"
button is pressed. This is a cumbersome and wasteful. Is there any
other way to do this?

Thanks in advance!

-- 

3. Activity - get notified when all views are rendered

4. How to scroll/move text within TextView on home screen widget ?

5. Supportting multiple MPEG-4 decoders??

6. cant compile android tree git://android.git.kernel.org

7. some quesitions for new decoder integration process of opencore framework