[android-developers] Digest for android-developers@googlegroups.com - 25 Messages in 12 Topics

Group: http://groups.google.com/group/android-developers/topics

    "SL@maxis" <ecp_gen@my-rialto.com> Dec 31 11:45AM +0800  

    > less efficient -- to simplify development, debugging and later,
    > maintenance
    > and enhancements.
     
    I have not thought about this; anyway I have been more active with PHP,
    javascript intepreted languages (before C/C++, occassional cursory look at
    Java).
     
    By the way you mean the current thinking is to convert binary data into
    ASCII representation ?
     
    I think hexadecimal notation (correct me if I am wrong), something like in
    an RTF file.
     
     
     
    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

     

    Miguel Morales <therevoltingx@gmail.com> Dec 30 07:49PM -0800  

    If you have a background with php and javascript you should already know
    about json.
    What are you trying to do? This sounds like something a simple webservice
    with a fileserver could easily do.
     
     
    --
    ~ Jeremiah:9:23-24
    Android 2D MMORPG: http://solrpg.com/,
    http://www.youtube.com/user/revoltingx

     

    "SL@maxis" <ecp_gen@my-rialto.com> Dec 31 12:25PM +0800  

    > What are you trying to do? This sounds like something a simple
    > webservice
    > with a fileserver could easily do.
     
     
    I have heard about 'json' but never bother with it. Those web related
    things are done with PHP and javascript without 'json'.
     
    Recently while I was planning to FTP some files onto a webserver with java
    that I discovered java does not provide FTP features (quite a let-down
    really). Of course 3rd-party library like apache provides such a service,
    but I am a bit reluctant to use a 3rd-party tool, always fearing the
    possibilty of a back-door virus. It was only then I realised that a PHP
    script on a webserver would do the job.
     
     
     
    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

     

    Miguel Morales <therevoltingx@gmail.com> Dec 30 08:32PM -0800  

    If you're doing web dev and don't know about json, you're probably doing
    something wrong.
    Anyway, good luck with your odd approach.
     
     
    --
    ~ Jeremiah:9:23-24
    Android 2D MMORPG: http://solrpg.com/,
    http://www.youtube.com/user/revoltingx

     

    barry <barry.drinkwater@gmail.com> Dec 30 03:54PM -0800  

    I have an app which uses a sqlite database and a ContentProvider to
    serve up data. The eclipse project has a unit test which adds a record
    to a database, retrieves it and asserts against the retrieved data:
     
    public void testAddNewVehicle() { Vehicle vehicle1 = new
    Vehicle("xyz", "my car", 111f); long result =
    VehicleProvider.addVehicle(getContext(), vehicle1);
     
    assertTrue(1 == result);
     
    ArrayList<Vehicle> vehicles =
    VehicleProvider.getVehicles(getContext()) ;
     
    assertEquals(1, vehicles.size()); assertEquals("xyz",
    vehicles.get(0).getRegistrationNo()); assertEquals("my car",
    vehicles.get(0).getDescription()); assertEquals(111.0f,
    vehicles.get(0).getInitialMileage()); }
     
    My setup method deletes the database:
     
    @Override protected void setUp() throws Exception { super.setUp();
    deleteTestDatabase(); }
     
    The test passes when I choose 'run', but if I choose debug, it fails
    at theassertEquals(1, vehicles.size()); line. After stepping through
    the code I have noticed something strange: even though the data
    insertion succeeds and assertTrue(1 == result); passes, the database
    does not exist on the file system at this point. It is only created
    when VehicleProvider.getVehicles(getContext()); is called.
     
    Both addVehicle() and getVehicles() result in a call
    togetWritableDatabase(), so I don't see why the first call does not
    create the database on disk. The addVehicle() method will eventually
    call insert() (irrelevant code omitted):
     
    @Override public Uri insert(Uri uri, ContentValues values) { String
    table = table = Constants.VEHICLE_TABLE_NAME;
     
    long rowID = UKMPGDataProvider.getWritableDatabase().in sert(table,
    null, values);
     
    // ---if added successfully---if (rowID > 0) { Uri insertedRowUri =
    insertedRowUri = ContentUris.withAppendedId(VEHICLE_CONTENT _URI,
    rowID);
     
    getContext().getContentResolver().notifyC hange(insertedRowUri, null);
    return insertedRowUri; } throw new SQLException("Failed to insert row
    into " + uri); }
     
    And the getVehicle() will eventually call query():
     
    @Override public Cursor query(Uri uri, String[] projection, String
    selection, String[] selectionArgs, String sortOrder)
    { SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
     
    sqlBuilder.setTables(uri.getPathSegments( ).get(0));
     
    if (uriMatcher.match(uri) == VEHICLE_ID) // ---if getting a particular
    vehicle
     
    sqlBuilder.appendWhere(BaseColumns._ID + " = " +
    uri.getPathSegments().get(1));
     
    if (sortOrder == null || sortOrder == "") { sortOrder =
    BaseColumns._ID; }
     
    Cursor c = sqlBuilder.query(UKMPGDataProvider.getWri tableDatabase(),
    projection, selection, selectionArgs, null, null, sortOrder);
     
    // ---register to watch a content URI for changes---
     
    c.setNotificationUri(getContext().getCont entResolver(), uri); return
    c; }
     
    As I say, the test passes when not in debug mode.

     

    barry <barry.drinkwater@gmail.com> Dec 30 04:02PM -0800  

    My apologies for the formatting in the original message!
     

     

    James Black <planiturthian@gmail.com> Dec 30 10:28PM -0500  

    Where is the database table created?

     

    yaqub ahmad <yaqubonnet@gmail.com> Dec 30 07:01PM -0800  

    Please see the code i am using for streaming shoutcast stream, it
    works with one URL but NOT with the other one.
     
    This one works:
     
    Uri myUri = Uri.parse("http://fr3.ah.fm:9000/");
     
    But not with this one:
     
    Uri myUri = Uri.parse("http://ib3.islambox.tv:8011/");
     
    SimpleMusicStream.java
     
    import android.app.Activity;
    import android.media.AudioManager;
    import android.media.MediaPlayer;
    import android.net.Uri;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
     
    public class SimpleMusicStream extends Activity implements
    MediaPlayer.OnCompletionListener,
    MediaPlayer.OnPreparedListener,
    MediaPlayer.OnErrorListener,
    MediaPlayer.OnBufferingUpdateListener {
     
    private String TAG = getClass().getSimpleName();
    private MediaPlayer mp = null;
     
    private Button play;
    private Button pause;
    private Button stop;
     
    @Override
    public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
     
    play = (Button) findViewById(R.id.play);
    pause = (Button) findViewById(R.id.pause);
    stop = (Button) findViewById(R.id.stop);
     
    play.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
    play();
    }
    });
     
    pause.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
    pause();
    }
    });
     
    stop.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
    stop();
    }
    });
    }
     
    private void play() {
    Uri myUri = Uri.parse("http://fr3.ah.fm:9000/");
    try {
    if (mp == null) {
    this.mp = new MediaPlayer();
    } else {
    mp.stop();
    mp.reset();
    }
    mp.setDataSource(this, myUri); // Go to Initialized state
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mp.setOnPreparedListener(this);
    mp.setOnBufferingUpdateListener(this);
     
    mp.setOnErrorListener(this);
    mp.prepareAsync();
     
    Log.d(TAG, "LoadClip Done");
    } catch (Throwable t) {
    Log.d(TAG, t.toString());
    }
    }
     
    @Override
    public void onPrepared(MediaPlayer mp) {
    Log.d(TAG, "Stream is prepared");
    mp.start();
    }
     
    private void pause() {
    mp.pause();
    }
     
    private void stop() {
    mp.stop();
     
    }
     
    @Override
    public void onDestroy() {
    super.onDestroy();
    stop();
     
    }
     
    public void onCompletion(MediaPlayer mp) {
    stop();
    }
     
    public boolean onError(MediaPlayer mp, int what, int extra) {
    StringBuilder sb = new StringBuilder();
    sb.append("Media Player Error: ");
    switch (what) {
    case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
    sb.append("Not Valid for Progressive Playback");
    break;
    case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
    sb.append("Server Died");
    break;
    case MediaPlayer.MEDIA_ERROR_UNKNOWN:
    sb.append("Unknown");
    break;
    default:
    sb.append(" Non standard (");
    sb.append(what);
    sb.append(")");
    }
    sb.append(" (" + what + ") ");
    sb.append(extra);
    Log.e(TAG, sb.toString());
    return true;
    }
     
    public void onBufferingUpdate(MediaPlayer mp, int percent) {
    Log.d(TAG, "PlayerService onBufferingUpdate : " + percent +
    "%");
    }
     
    }
     
     
     
    main.xml:
     
     
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
    android:text="Play"
    android:id="@+id/play"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></Button>
    <Button
    android:text="Pause"
    android:id="@+id/pause"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></Button>
    <Button
    android:text="Stop"
    android:id="@+id/stop"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></Button>
    </LinearLayout>
     
    The Log-cat shows errors:
     
    NuHTTPDataSource(33): Server did not give us the content length!
     
    Media Player Error: Unknown (1) -2147483648
     
     
    Can someone help me to fix it?
     
    Thanks

     

    Sean751 <sean751@gmail.com> Dec 30 07:00PM -0800  

    Thanks for responding,
    I still have a problem
    I can do a method for
    public boolean onGroupClick(ExpandableListView parent, View v,int
    groupPosition, long id) {} but it does nothing when a group is
    clicked.
    If I add
    getExpandableListView().setOnGroupClickListener((OnGroupClickListener)
    this); it asks me to type cast 'this'. Then the application crashes on
    run. I suppose onclick must be used for changing the display could the
    conflict be the problem?
    Any ideas
    Thanks
    Sean
     
     

     

    Jeresam515 <jeremyschiff515@gmail.com> Dec 30 11:45AM -0800  

    The solution I found is to change deleteallnotes() to: public void
    deleteAllNotes() { mDb.execSQL("DROP TABLE IF EXISTS
    notes");mDb.execSQL(DATABASE_CREATE); }
     

     

    lbendlin <lutz@bendlin.us> Dec 30 05:31PM -0800  

    if you only have a few entries then "Drop table" is a bit of an overkill.
    Simply issuing "Delete from table" is sufficient in most cases.

     

    barry <barry.drinkwater@gmail.com> Dec 30 04:05PM -0800  

    I have an app that uses a ContentProvider to serve data instead of
    directly accessing the database. The application is working as
    expected but I have a problem with unit tests: how can I force the
    ContentProvider to use a test database rather than a 'live' one? If I
    wasn't using a ContentProvider I could pass a different database name
    to the Constructor of my `SQLiteOpenHelper` sublass, but now the
    database is created with a call to onCreate() in my ContentProvider:
     
    @Override
    public boolean onCreate()
    {
    UKMPGDataProvider.init(getContext(), Constants.DATABASE_NAME);
    return (UKMPGDataProvider.getWritableDatabase() == null) ? false :
    true;
    }
     
    As you can see, the database name is hardcoded.
     
    Is there a way to pass a test name into the ContentProvider?

     

    TurboMan <yusufcelik@gmail.com> Dec 30 11:25AM -0800  

    Hi,
     
    Would that cause any trouble if I initiate second AsyncTask thread right at
    the onPostExecute event of first AsyncTask?
     
    Regards
    TM

     

    TurboMan <yusufcelik@gmail.com> Dec 30 11:27AM -0800  

    I may ask the question in another way.
    What is the best way to execute more than one thread after completion of
    another?

     

    Mukesh Srivastav <mukichamps@gmail.com> Dec 31 01:00AM +0530  

    What are you trying to really achieve with that ?
     
    secondly, onpostExecute() is the one which actually executed lastly, i mean
    after doInbackground(), it means that it executes after your firstAsyncTask
    is finished and i dont see any problem as long your close all the created
    objects in preExecute before calling the Second AsyncTask.
     
     
    One of My blog on Android using one Generic ASYNCTask for all the
    Activities.
     
    http://www.androidsnippets.com/asyntask-in-android
     
    --
    Warm Regards,
    *Mukesh Kumar*,
    Android Consultant/Freelancer,
    India,Hyderabad.
     

     

    TurboMan <yusufcelik@gmail.com> Dec 30 12:47PM -0800  

    Thanks Mukesh,
     
    The reason I am trying to do this is:
    After I download a file then I wish to process the file in another thread*.
    *So I have to wait the first thread to finish its job.
     
    Regards
    TM*
    *

     

    TurboMan <yusufcelik@gmail.com> Dec 30 01:26PM -0800  

    So I can notify the user

     

    Jeresam515 <jeremyschiff515@gmail.com> Dec 30 11:46AM -0800  

    So I'm making a simple painting app for the Android SDK. However, the
    onTouchEvent() is only getting some of the events not all of them(if I
    drag my finger across the screen it gets roughly half of the
    events(points)) Here is my OnTouchEvent():
     
    @Override
    public boolean onTouchEvent(MotionEvent event) {
    mDbHelper.createNote(event.getX(), event.getY(), 11);
    NotesMade ++;
    mLemonadeMainMenuView.setCoords(NotesMade);
    return true;
    }
     
     
    private void doDraw(Canvas canvas) {
    canvas.drawColor(Color.TRANSPARENT);
    Paint paint = new Paint();
    paint.setColor(Color.BLUE);
    paint.setStyle(Style.FILL);
    int mNoteId = 0;
    while(mNotesMade>mNoteId)
    {mNoteId++;
    Cursor note = mDbHelper.fetchNote(mNoteId);
    Float x;
    Float y;
    Float size;
    x =
    Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_X)));
    y=
    Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_Y)));
    size =
    Float.valueOf(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_Size)));
    canvas.drawCircle(x, y, size, paint);}
    }}
     
    Drawing portion above. Logcat also reveals nothing. Help would be
    greatly appreciated. How can I fix my OnTouchEvent()?

     

    guich <guihazan@gmail.com> Dec 30 11:06AM -0800  

    Hi,
     
    I store some zipped data in the assets. When my app runs at the first
    time, i unpack the zip. The original zip in the assets folder is
    useless, however, we cannot delete it.
     
    Is there another way to pack files into an apk that we can later
    delete after using it?
     
    thanks
     
    guich

     

    guich <guihazan@gmail.com> Dec 30 11:08AM -0800  

    On a side note, is it possible to get the creation data and time of
    the asset file?

     

    Romain Guy <romainguy@android.com> Dec 30 10:17AM -0800  

    If that happens it means you are creating your OpenGL context on the
    UI thread. Or that you are running some of your GL code on the UI
    thread. I have seen apps do this before (Google Maps had such a bug
    before we shipped 4.0 for instance.)
     
    Drivers usually generate the same series of names when you invoke
    glGenTextures(). For instance, if you invoke glGenTextures() in two
    different GL contexts on two different threads, both calls will return
    the same value (for instance 1 on Tegra.) This means that if you run
    your code on the wrong context/thread you are likely to use a texture
    that's not yours but has the same identifier.
     
    If you are creating your OpenGL context on the UI thread you should
    always make sure to call eglMakeCurrent() before you do anything else,
    otherwise your GL commands will run on the context created by the UI
    toolkit.
     
    If you creating your OpenGL context on another thread, make sure that
    all of your GL commands are executed on that particular thread.
     
     
    --
    Romain Guy
    Android framework engineer
    romainguy@android.com

     

    petter <petter.gustad@gmail.com> Dec 30 04:01AM -0800  

    In my application I dynamically create buttons, but it would be better
    if I could specify a button in the resource file and then clone it to
    inherit its style, size, etc. But how do you clone a button or other
    view object? I've tried to call .clone() but I seem to get all sorts
    of errors and warnings, probably because I'm not casting in the right
    order.

     

    skink <pskink@gmail.com> Dec 30 04:18AM -0800  

    petter wrote:
    > view object? I've tried to call .clone() but I seem to get all sorts
    > of errors and warnings, probably because I'm not casting in the right
    > order.
     
     
    use LayoutInflater
     
    pskink

     

    surabhi jain <surabhi17.jain@gmail.com> Dec 30 05:22PM +0530  

    I'd like to know which is the intent android sends when it sends a message.
    And how can I listen for this intent in my application. I wanted that, when
    I send a message in native android messaging, my application listen this
    intent, so it will know a new message has been sent.
     
    So, which one is it, and how to listen for this intent?

     

You received this message because you are subscribed to the Google Group android-developers.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment