Problems writing a C2DM service (InstantiationException).

by Cristian Udrea » Sat, 12 Feb 2011 06:07:38 GMT


Sponsored Links
 Hello everybody.
I'm trying to implement a C2DM service over a barebones "hello world"
application with two buttons.
At first I used a BroadcastReceiver, but it has a 10 second execution
limit and a few other limitations,
so I thought it would be better to use the IntentService approach
(google's C2DM samples).
I picked the crome-to-phone example.

The problem is that  when executing the following lines:

    static void runIntentInService(Context context, Intent intent) {
        if (mWakeLock == null) {
            // This is called from BroadcastReceiver, there is no
init.
            PowerManager pm =
                (PowerManager)
context.getSystemService(Context.POWER_SERVICE);
            mWakeLock =
pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
                    WAKELOCK_KEY);
        }
        mWakeLock.acquire();

        intent.setClassName(context,
"com.example.helloandroidc2dm.C2DMReceiver");
        context.startService(intent); <=== HERE
    }

the JVM throws what seems to be a recursive InstantiationException.

Normally, that would be because of abstract methods, but after
changing the class to no longer
be an abstract class, it still happens.

Does anyone have (at least) a pointer for where I should start
debugging ?

Thanks in advance.

-- 



Other Threads

1. MediaStore.ACTION_IMAGE_CAPTURE + Intent.FLAG_GRANT_WRITE_URI_PERMISSION

I was hoping to take a photo and enable only the camera app (or whatever
other app is bound to ACTION_IMAGE_CAPTURE) to store a photo in my content
provider.

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, MyPhotoStore.URI);

    // Grant permission to the camera activity to write the photo.
    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    intent.setData(MyPhotoStore.URI);

    startActivityForResult(intent, REQUEST_PHOTO);

Calling setData() on the URI enables the other app to write to the URI, but
it also messes up the activity dispatch (I get ActivityNotFoundException).

I'd rather not specify a package with Context.grantUriPermission() because I
want it to work for any activity bound to ACTION_IMAGE_CAPTURE.

Is there any way to use FLAG_GRANT_WRITE_URI_PERMISSION
with ACTION_IMAGE_CAPTURE?

I guess an alternative is to use random URIs instead of the built-in
security.

Thanks,
Bob

-- 

2. Madu & Racun

Madu smua tuh suhu....... kloteran dunks.. wkakakaka...

~~~
@leonardusjeff
~~~~~~
# powered by Google Phone #

On Feb 18, 2010 2:06 AM, "Subanindiyo Ardi" <subanindiyo.a...@gmail.com>



 Yg mana yg madu yg mana yg racun nih....:).

-- 
"Indonesian Android Community [id-android]"

3. Broadcast/notify/message when application is launched

4. mau tanya dong....need help

5. Package tracker

6. Search Market by Publisher Name

7. Kloteran Nexus Mugen 1600mAH