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. Why My application could play http but not rtsp?

I wrote a application .It could playback the internet video and
audio , if I give it a address begin with "http://".But when I input
the address that is beginning with the "rtsp://",It could not play.

Log:
I/ActivityManager( 1074): Process com.android.voicedialer (pid 2152)
has died.
I/ActivityManager( 1074): Low Memory: No more background processes.
D/skia    ( 1122): purging 10K from font cache [1 entries]
I/ActivityManager( 1074): Starting activity: Intent
{ act=android.intent.action.MAIN cat=
[android.intent.category.LAUNCHER] flg=0x10200000
cmp=com.android.Test/.Test_Main }
I/ActivityManager( 1074): Start proc com.android.Test for activity
com.android.Test/.Test_Main: pid=2163 uid=10020 gids={}
I/WindowManager( 1074): Setting rotation to 1, animFlags=0
I/WindowManager( 1074): Config changed: { scale=1.0 imsi=0/0 loc=en_US
touch=3 keys=1/1/2 nav=1 orien=2}
D/StatusBar( 1074): updateResources
W/IInputConnectionWrapper( 1122): showStatusIcon on inactive
InputConnection
I/ActivityManager( 1074): Displayed activity
com.android.Test/.Test_Main: 989 ms (total 989 ms)
I/ActivityManager( 1074): Starting activity: Intent
{ cmp=com.android.Test/.StreamTest.Test }
I/ActivityManager( 1074): Displayed activity
com.android.Test/.StreamTest.Test: 137 ms (total 137 ms)
I/ActivityManager( 1074): Starting activity: Intent
{ act=android.intent.action.VIEW dat=rtsp://125.76.233.38/h264.3gp
typ=video/* cmp=com.android.camera/.MovieView }
I/ActivityManager( 1074): Start proc com.android.camera for activity
com.android.camera/.MovieView: pid=2170 uid=10003 gids={1006, 1015,
2001, 3003}
W/InputManagerService( 1074): Starting input on non-focused client
com.android.internal.view.iinputmethodclient$stub$pr...@4384c6a8
(uid=10020 pid=2163)
W/IInputConnectionWrapper( 2163): showStatusIcon on inactive
InputConnection
V/VideoView( 2170): reset duration to -1 in openVideo
I/ActivityManager( 1074): Displayed activity
com.android.camera/.MovieView: 2300 ms (total 2300 ms)
I/ActivityManager( 1074): Process com.android.Test (pid 2163) has
died.
I/WindowManager( 1074): WIN DEATH: Window{437bb600 com.android.Test/
com.android.Test.Test_Main paused=false}
I/WindowManager( 1074): WIN DEATH: Window{4381f0c8 com.android.Test/
com.android.Test.StreamTest.Test paused=false}
I/ActivityManager( 1074): Low Memory: No more background processes.
W/QCvdec  ( 1029): get_parameter: unknown param 0ff7a347
D/skia    ( 1122): purging 33K from font cache [4 entries]
D/skia    ( 1074): purging 43K from font cache [6 entries]
D/skia    ( 2170): purging 21K from font cache [3 entries]
E/PlayerDriver( 1029): Command PLAYER_PREPARE completed with an error
or info PVMFFailure
W/PlayerDriver( 1029): PVMFInfoErrorHandlingComplete
E/MediaPlayer( 2170): error (1, -1)
E/MediaPlayer( 2170): Error (1,-1)
D/VideoView( 2170): Error: 1,-1
E/MediaPlayer( 2170): stop called in state 0
E/MediaPlayer( 2170): error (-38, 0)



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

2. Apn Switching to default

Hi,

when ever Apn Swithed to default, if already one data application is
running with the specified APN, Does it will wait up to that data
application ends? or it will close that Data application also?

How can we set our Specified APN from the application?


Thanks
Santosh.
--~--~---------~--~----~------------~-------~--~----~

3. Problem with Dialog theme when launching from another activity

4. setImageMatrix has no effect?

5. Help on android-port to mini2440

6. Android NDK ( Native code Debugging)

7. How to do we take a Screenshot using ADB Comand Line