How to setup Access Point parameters programmatically

by luc276 » Thu, 30 Apr 2009 02:05:56 GMT


Sponsored Links
 Hi all
First I'm using the Android SDK 1.5 with ADT 0.9 and I'm investigating
with the emulator.
I'm wondering how to setup the Andoid Access Point parameters (like
APN, username, password..) programmatically.
I saw a WRITE_APN_SETTINGS permission in the SDK help but didn't find
any way to use it.
I guess the settings are stored into /data/data/
com.android.providers.telephony/databases/telephony.db and  into /data/
data/com.android.providers.telephony/shared_prefs/preferred-apn.xml
but I cannot access them programmaticaly.
Indeed, when I call
SQLiteDatabase myDB = SQLiteDatabase.openDatabase("/data/data/
com.android.providers.telephony/databases/telephony.db", null,
SQLiteDatabase.OPEN_READONLY);
an SQLiteException is thrown (830058649800) "unable to open database
file".
I tried to define in the manifest several permissions like
CHANGE_CONFIGURATION, WRITE_SETTINGS but without more success. Just
noticed that I can access the two files with with "adb shell sqlite3"
or DDMS and pull them from the emulator to the PC.
I'm working on the topic since a week and I'm really in hurry right
now so your helps will be greatly appreciated.
Thanks in advance
Regards
luc

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



Other Threads

1. Flickering camera preview in SurfaceView

Hi,

I have an Dialog with a custom view. This view has a SurfaceView which
shows a camera preview. However, the preview is very flickering.

The taken photo does not contain flicker. It looks as it should.

Why does the preview flicker? (The camera does work :-) )

This is my custom view:
---------

public class CameraView extends LinearLayout implements
SurfaceHolder.Callback, OnClickListener, PictureCallback {

        private SurfaceView surfView;
        private SurfaceHolder previewHolder;
        private Camera camera;
        OnProfilePictureTakenListener onProfilePictureTakenListener = null;

        public CameraView(Context context) {
                super(context);
                setOnClickListener(this);
                surfView = new SurfaceView(getContext());
                addView(surfView);
                previewHolder = surfView.getHolder();
                previewHolder.addCallback(this);
                previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int
width,
                        int height) {
                Camera.Parameters parameters = camera.getParameters();
                parameters.setPreviewSize(width, height);
                parameters.setPictureFormat(PixelFormat.JPEG);
                camera.setParameters(parameters);
                camera.startPreview();
        }

        @Override
        public void surfaceCreated(SurfaceHolder holder) {
                camera = Camera.open();
                try {
                        camera.setPreviewDisplay(previewHolder);
                } catch(Throwable t) {
                        Log.e("surfaceCallback", "Exception", t);
                        Toast.makeText(getContext(), t.getMessage(), 
Toast.LENGTH_LONG).show
();
                }
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
                camera.stopPreview();
                camera.release();
                camera = null;
        }

        @Override
        public void onClick(View v) {
                takePicture();
        }

        private void takePicture() {
                camera.stopPreview();
                camera.takePicture(null, null, this);
        }

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {
                new SavePhotoTask().execute(data);
                camera.startPreview();
        }

        public void setOnPictureTakenListener(OnProfilePictureTakenListener
lis) {
                onProfilePictureTakenListener = lis;
        }

        class SavePhotoTask extends AsyncTask<byte[], String, String> {

                @Override
                protected String doInBackground(byte[]... jpeg) {
                        File photo = new 
File(Environment.getExternalStorageDirectory(),
"/.addMePictures/" + System.currentTimeMillis());
                        if(photo.exists()) {
                                photo.delete();
                        }
                        try {
                                FileOutputStream fos = new 
FileOutputStream(photo.getPath());
                                fos.write(jpeg[0]);
                                fos.close();
                        } catch(IOException e) {
                                e.printStackTrace();
                        }
                        if(onProfilePictureTakenListener != null) {
                                
onProfilePictureTakenListener.onProfilePictureTaken(photo);
                        }
                        return null;
                }

        }

        public interface OnProfilePictureTakenListener {
                public abstract void onProfilePictureTaken(File imgFile);
        }

}


--------

Thank you very much!

//Kaloer

-- 

2. Market T Mobile Carrier Billing

kabarnya sdh ada update market yg memberikan kita pilihan untuk membayar 
aplikasi lewat billing operator (hanya di t mobile)..klo gini ga repot 
nih...siap2 bubye app retakan..going to legite...lol..

Semudah pasang RBT ...

Hayoo operator indo..majuuuuuuu....perjuangkan gms dan carrier billing di 
market...doh!
--
Sent from my Android phone with K-9. Please excuse my brevity.

-- 
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. Getting hold of PreferenceActivity Views from the xml file

4. Updating my calendar

5. Cannot build Android source in Ubuntu

6. Your Best App?

7. ROM : Cyanogen V.4.2.8 is OUT!!! :D