Why is the same dialog sometimes translucent?

by Carl Whalley » Fri, 02 Apr 2010 21:36:41 GMT


Sponsored Links
 I have a Dialog with a Button whos OnClickListener() creates an
AlertDialog:
public void onClick(View v) {
  Dialog confirmDialog = new AlertDialog.Builder( activity )
                        .setIcon( R.drawable.icon )
...

The problem is in one place in the app, actually a MapActivity derived
Activity, when I run this the confirmDialog is translucent, and I
don't want this. When I run the same code from various other points in
the app, all non MapActivity derived, the confirmDialog has a solid
background. So its unlikely to be anything in the Dialogs xml but more
the context it is launched from, but I can't for the life of me see
where any translucent style is even mentioned in the app. Has anyone
see this before, or got any hints for how I can stop it happening
please?

--
Android Academy:  http://androidacademy.com 

--



Other Threads

1. Problems in uploading my entry

The form is giving a 502 server error ? Anything wrong with the
server ?

regards,
Prekshu
--~--~---------~--~----~------------~-------~--~----~

2. Problem on playing 3gp file

HI ,
I am getting problem while playing 3gp file from url
problem is that the video is play for only few sec.
not completely.
please help me its urgent .
I have Sending my code
Thank you in advance

 package com.org.video;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.webkit.URLUtil;
import android.widget.EditText;
import android.widget.ImageButton;

public class VideoPlayer extends Activity implements OnErrorListener,
OnBufferingUpdateListener, OnCompletionListener, OnPreparedListener
{
        public static final String TAG = "VideoPlayer";
        private MediaPlayer mp ;
        private SurfaceView mPreview;
        private EditText mPath;
        private ImageButton mPlay ;
        private ImageButton mPause;
        private ImageButton mStop,mReset;
        private SurfaceHolder holder;
        private String current;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        mPreview = (SurfaceView) findViewById(R.id.surface);
        mPlay = (ImageButton) findViewById(R.id.play);
        mPause = (ImageButton) findViewById(R.id.pause);
        mStop = (ImageButton) findViewById(R.id.stop);
        mPath = (EditText) findViewById(R.id.path);
        mReset = (ImageButton) findViewById(R.id.reset);
        mPlay.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View view)
            {
                playVideo();
            }
        });


        mPause.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.pause();
                }
            }
        });

        mReset.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.seekTo(0);
                }
            }
        });


        mStop.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (mp != null) {
                    mp.stop();
                    mp.release();
                }
            }
        });
        //      Set the transparency
        getWindow().setFormat(PixelFormat.RGBA_8888);
        //      Set a size for the video screen
        holder = mPreview.getHolder();
       // holder.setCallback(this);
        holder.setFixedSize(400, 300);
    }

    public void playVideo()
    {
        try
        {
                final String path = mPath.getText().toString();

                Log.v(TAG,"payh : "+path);

                //If the path has not changed, just start the media player
                if(path.equals(current) && mp != null)
                {
                        mp.start();
                        return ;

                }
                current = path ;
                  // Create a new media player and set the listeners
                        mp = new MediaPlayer();
                        mp.setOnErrorListener(this);
                        mp.setOnBufferingUpdateListener(this);
                        mp.setOnCompletionListener(this);
                        mp.setOnPreparedListener(this);
                        mp.setAudioStreamType(2);

                        // Set the surface for the video output
                        mp.setDisplay(mPreview.getHolder().getSurface());

                        // Set the data source in another thread
                // which actually downloads the mp3 or videos
                // to a temporary location
                        Runnable r = new Runnable()
                        {
                                public void run()
                                {
                                        try
                                        {
                                                setDataSource(path);
                                                mp.prepare();
                            Log.v(TAG, "Duration:  ===> " +
mp.getDuration());
                            mp.start();

                                        }
                                        catch(Exception e)
                                        {
                                                Log.e(TAG, e.getMessage(), e);
                                        }

                                }
                        }; new Thread(r).start();


        }
        catch(Exception e)
        {
                Log.e(TAG, e.getMessage(), e);
                 if (mp != null)
                 {
                 mp.stop();
                 mp.release();
                 }
        }
    }

    /**
     * If the user has specified a local url, then we download the
     * url stream to a temporary location and then call the
setDataSource
     * for that local file
     *
     * @param path
     * @throws IOException
     */
    public void setDataSource(String path)throws IOException
    {
        if(!URLUtil.isNetworkUrl(path))
        {
                Log.i("Not NetworkUrl","setDataSource");
                mp.setDataSource(path);
        }
        else
        {
                URL url = new URL(path);
                URLConnection cn = url.openConnection();
                cn.connect();
                InputStream stream = cn.getInputStream();
                if(stream == null)
                {
                         throw new RuntimeException("stream is null");
                }
            File temp = File.createTempFile("mediaplayertmp", "dat");
            String tempPath = temp.getAbsolutePath();
            FileOutputStream out = new FileOutputStream(temp);
            int i=0;
            byte buf[] = new byte[255];
            do
            {
                 int numread = stream.read(buf);
                 if (numread <= 0)
                 {
                           break;
                 }
                 out.write(buf, 0, numread);
                 Log.e(TAG,"Inside the While loop"+i);
                 ++i;

            }while(true);
            mp.setDataSource(tempPath);
            try
            {
                stream.close();
            }
            catch (IOException ex)
            {
                Log.e(TAG, "error: " + ex.getMessage(), ex);
            }
        }

    }

        public void onError(MediaPlayer mediaPlayer, int arg1, int arg2)
        {
                Log.e(TAG, "onError--->   what:" + arg1 + "    extra:" + arg2);
                if (mediaPlayer != null)
        {
           mediaPlayer.stop();
           mediaPlayer.release();
        }

        }

        public void onBufferingUpdate(MediaPlayer arg0, int arg1)
        {
                Log.d(TAG, "onBufferingUpdate called --->   percent:" + arg1);

        }

        public void onCompletion(MediaPlayer arg0)
        {
                Log.d(TAG, "onCompletion called");

        }

        public void onPrepared(MediaPlayer arg0)
        {

                 Log.d(TAG, "onPrepared called");
        }

        public boolean surfaceCreated(SurfaceHolder surfaceholder)
         {
                Log.d(TAG, "surfaceCreated called");
                return true;
         }

}


please help me
--~--~---------~--~----~------------~-------~--~----~

3. iPhone SDK lacks mapping function

4. Load a class from another .apk file dynamic?

5. Creating an XML file from Code

6. ROMs for Current Hardware?

7. Starting Google NotePad by firing Intent