Turning off Android notifications.(Battery/Bluetooth)

by Pobudzio » Tue, 07 Sep 2010 16:40:04 GMT


Sponsored Links
 Hi,

My first question is about low battery notification. I would like turn
off this popup which oocurs when battery is low during my application
is on. I can catch of course Intent.ACTION_BATTERY_LOW but additionaly
Android show me this popup. Is it possible to turn it off?

Second topic is about turning on bluetooth. When I turn it on using
API system show me additional popup asking if I agree to turn on
bluetooth module by this application. Is it possible to turn off this
popup. I have HTC Legend on which popup occures and my friend has
Motorola Milestone on which it doesn't occur. So probably it's only in
HTC Andoid implementation.


regards,
Pobudzio

--



Turning off Android notifications.(Battery/Bluetooth)

by Mark Murphy » Tue, 07 Sep 2010 19:39:11 GMT


 


I see no evidence that ACTION_BATTERY_LOW is an ordered broadcast, in
which case you cannot "turn it off".

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training in London:  http://skillsmatter.com/go/os-mobile-server 

--


Sponsored Links


Other Threads

1. calling .NET webservice using ksoap Android

Hi All,

Same question is asked previously in this forum. I am asking it again
after referring all question in this forum.

Problem :- I am trying call call .NET Web service from Android device.
I can call web service without parameter successfully; but when tried
to pass parameter it shows null in server side log.

Technology/API used : -

-> KSOAP 2.0 for Android

-> .NET Framework 3.5 + WCF Web service

-> Web service type is document literal.

Point to be noted over here is same service working fine with
normal .NET Web service.

Before I post my code here is my trying so far,

1. As suggested in this forum, I have changed server side NAMESPACE to
URI not URL. For i.e. - Previously it was http://tempurl.com and now i
have changed it to uri:myService

2. I am adding XML header in the request, even tried to by removing
it. i.e - httpTransport.setXmlVersionTag("<?xml version=\"1.0\"
encoding= \"UTF-8\"?>");

3. I have enabled the Access data sources across domains IE option in
server side/client side.

Code looks like below,

request = new SoapObject(Util.NAMESPACE, method);
request.addProperty("name", value);
soapEnvelope = new
SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
    httpTransport = new HttpTransportSE(Util.URL);
    soapEnvelope.dotNet = true;
    soapEnvelope.setOutputSoapObject(request);
    httpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=
\"UTF-8\"?>");
    httpTransport.call(SOAP_ACTION, soapEnvelope);

I have end up spending lots of time in this issue.
Help will be appreciated.

-- 

2. Key Dispatching Time Out problem

Hi, I am trying to buffer a video stream and play the video from the
buffer file, but it seems not to work. I check the logcat, it says
something about Key "Dispatching Time Out problem". Does anyone know
what's wrong? The problem is probably due to CPU consuption because
this error appears after I wrong the same programme several times.
Here is my code.

package com.example.Client2;

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.os.Bundle;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnCompletionListener;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.webkit.URLUtil;
import android.widget.ImageButton;
import android.widget.Button;
import android.util.Log;
import android.view.View;

//import android.view.Display;
//import android.view.WindowManager;
//import android.view.ViewGroup.LayoutParams;
//import android.widget.RelativeLayout;
//import android.view.Gravity;



public class Client2 extends Activity implements
                                      OnBufferingUpdateListener,
                                      OnCompletionListener,
                                      MediaPlayer.OnPreparedListener,
                                      SurfaceHolder.Callback{

        private static final String TAG="MediaPlayer";
        private MediaPlayer         mMediaPlayer;
        private SurfaceView         mPreview;
        private SurfaceHolder       holder;
        private String              path;
        private int                 mVideoWidth;
        private int                 mVideoHeight;
    private static final int LOCAL_VIDEO = 1;
    private static final int STREAM_VIDEO = 2;
        //private static final int CENTER = 17;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mPreview=(SurfaceView) findViewById(R.id.surface);
        holder=mPreview.getHolder();
        holder.addCallback(this);
        //holder.setFixedSize(30, 30);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        ImageButton Play = (ImageButton) findViewById(R.id.play);
        ImageButton Pause = (ImageButton) findViewById(R.id.pause);
        Button Stream = (Button) findViewById(R.id.stream);

        //checkOrientation();

        Play.setOnClickListener(new View.OnClickListener(){
                public void onClick(View view){
                        playVideo(LOCAL_VIDEO);
                }
        });

        Pause.setOnClickListener(new View.OnClickListener(){
                public void onClick(View view){
                        mMediaPlayer.pause();
                }
        });

        Stream.setOnClickListener(new View.OnClickListener(){
                public void onClick(View view){
                        playVideo(STREAM_VIDEO);
                }
        });
    }

/*  private void checkOrientation()
    {
         WindowManager wm = getWindowManager();
         Display d = wm.getDefaultDisplay();
                 Log.d(TAG,"ok1");

         LayoutParams params;

         Log.d(TAG,"ok2");
         if (d.getWidth() > d.getHeight())
         {
                Log.d(TAG,"ok3");
             //---landscape mode---
             params = new RelativeLayout.LayoutParams(200,200);
             Log.d(TAG,"ok4");

         }
         else
         {
             //---portrait mode---
             params = new RelativeLayout.LayoutParams(200,200);
         }
             Log.d(TAG,"ok5");
         mPreview.setLayoutParams(params);
    }*/

    private void playVideo(Integer Media)
    {
        try
        {
                switch (Media){
                case LOCAL_VIDEO:
                path="/sdcard/toystory3.3gp";
                break;
                case STREAM_VIDEO:
            Log.d(TAG,"check");
                //path="rtsp://172.17.179.200:5544/stream";
            path="http://172.17.179.200:8080/stream";
                break;
                }

                mMediaPlayer=new MediaPlayer();
                Log.d(TAG,"Here...");
            //setDataSource(path);
                mMediaPlayer.setDataSource(path);
                mMediaPlayer.setDisplay(holder);
                mMediaPlayer.prepare();

                mMediaPlayer.setOnBufferingUpdateListener(this);
                mMediaPlayer.setOnCompletionListener(this);
                mMediaPlayer.setOnPreparedListener(this);

                mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
                Log.d(TAG,"Debug");
                mVideoWidth=mMediaPlayer.getVideoWidth();
                mVideoHeight=mMediaPlayer.getVideoHeight();
                holder.setFixedSize(mVideoWidth,mVideoHeight);
                        mMediaPlayer.start();
                        //mMediaPlayer.stop();
                        //mMediaPlayer.release();
        }
        catch (Exception e)
        {
                Log.e(TAG,"error:"+e.getMessage(),e);
        }
    }

    private void setDataSource(String path) throws IOException{
        //Log.d(TAG,"Here...");
        if (!URLUtil.isNetworkUrl(path)){
                //mMediaPlayer.setDataSource(path);
        }else{
                Log.d(TAG,"Here...");
                URL url=new URL(path);
                URLConnection cn = url.openConnection();
                Log.d(TAG,"Hereok...");
                cn.connect();
                Log.d(TAG,"Hereok1...");
                InputStream stream = cn.getInputStream();
                if (stream==null)
                        throw new RuntimeException("stream is null");
                //Log.d(TAG,"Hereok...");
                File temp=File.createTempFile("mediaplayertmp","dat");
                String tempPath=temp.getAbsolutePath();

                FileOutputStream out=new FileOutputStream(temp);

                byte buf[]=new byte[20];
                do{
                        int numread=stream.read(buf);
                        if(numread<=0)
                                break;
                        out.write(buf, 0, numread);
                        Log.d(TAG,"Hereok...");
                }while(true);
                mMediaPlayer.setDataSource(tempPath);
                try{
                        stream.close();
                }catch(IOException ex){
                        Log.e(TAG,"error:"+ex.getMessage(),ex);
                }
        }
    }
        @Override
        public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2,
int arg3) {
                // TODO Auto-generated method stub

        }
        @Override
        public void surfaceCreated(SurfaceHolder arg0) {
                Log.d(TAG,"SurfaceCreated called");
        }
        @Override
        public void surfaceDestroyed(SurfaceHolder arg0) {
                // TODO Auto-generated method stub

        }
        @Override
        public void onPrepared(MediaPlayer arg0) {
                Log.d(TAG,"OnPrepared called");
                //playVideo();
        }
        @Override
        public void onCompletion(MediaPlayer arg0) {
                // TODO Auto-generated method stub

        }
        @Override
        public void onBufferingUpdate(MediaPlayer arg0, int arg1) {
                // TODO Auto-generated method stub

        }
}

-- 

3. project help

4. bitmap size exceeds VM budget

5. How can I use different row view for selected or unselected list item?

6. Video streaming from android mobile phone to a remote computer

7. How to get Android Source code?