Android Bug/Architectural Issue: How do I handle multiple versions of my own Content Provider?

by whitemice » Thu, 08 Jan 2009 23:18:16 GMT


Sponsored Links
 Ie blogged this question with pictures here:
 http://tinyurl.com/9hwdva 

I am writing a component that makes certain functionality available to
any application running on an Android device (e.g. an advertising
service, stock ticker cache, Snowball server, etc).

This functionality is useful for application developers, but not
interesting to actual users i.e. my component should be included as
part of a new application, but not require the end user to explicitly
install the additional component themselves.

I expect that over time multiple applications installed on the phone
will want to communicate with my component.  As each new application
will have a different certificate, I want to communicate between
applications using an Android Content Provider.  To save resources on
the device (networking, caching, etc) only one instance of my
component should be appointed to handle all queries.

This works well as Android only registers the first Content Provider
for a given URI and then ignores the rest (throwing an ARN/
PackageManager: Skipping provider name xxxx name already usederror
each time a new one is installed).

However if the registered Content Provider is uninstalled, it will
immediately break all the other applications that rely on it, even
though other instances of the component still exist.

Questions:
- Does anyone have any suggestions on how to better handle this
situation?
- If I could reregister Content Providers I could handle situations
like this, and upgrade components when newer versions are installed.
Perhaps the Android OS could also handle this situation better, by
tracking Content Provider naming collisions?
- Should I be looking at other communication methods to solve this
issue?


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



Other Threads

1. Help: Issue with Android GridView, TouchListener and onTouch()

I am using the following code to do things with gridview(slightly
modified from 
http://developer.android.com/resources/tutorials/views/hello-gridview.html).
I want to replace the onClicklistener and the onClick() method with
their "touch" equivalents i.e. touchlistener and onTouch() so that
when i touch an element in the gridview the image of the element
changes and a double touch on the same element takes it back to the
orginal state.

How do I do this? I can't get my code to do this. The clicklistener
works to some extent but the touch isn't. Please help.

public class ImageAdapter extends BaseAdapter {
private Context mContext;

public ImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return mThumbIds.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent)
{
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize
some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);

        imageView.setOnClickListener(new View.OnClickListener()
            {

              @Override
              public void onClick(View view)
{

                  if(position==0)
                  {
                                  //do this
                              }
                              else
                              {
                                //do this
                              }
                           }
                    });

    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
}

// references to our images
private Integer[] mThumbIds = {
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7,
        R.drawable.sample_0, R.drawable.sample_1,
        R.drawable.sample_2, R.drawable.sample_3,
        R.drawable.sample_4, R.drawable.sample_5,
        R.drawable.sample_6, R.drawable.sample_7
};
}

-- 

2. Search, Result and Detail workflow inside a tab

Well, here is a method that I can think of.

1. Create multiple View classes which prepare the layout and handle
all the actions on that view.
One for each, SearchView, ResultView and DetailView.

2. In the activity, get the first view and set it as content to the
activity.

3. When the user navigates, keep an ArrayList of Views so that you can
maintain the state of the previous screens.

4. Handle the Back button press, and change the Activity's content to
the required view.

Instead of setting the content, you can also use a simple ViewFlipper
to create animations while changing views.

Thanks and Regards,
Kumar Bibek




-- 

3. Got my free droid today from google

4. md5sum on the file

5. user agent of the device ..

6. Contacts from 1.5 and 1.6 ... filtering out trash

7. Progress dialog question/problem (API Demos example)