Problem in identifying which widget click is launching the activity?

by dark_messiah » Mon, 08 Jun 2009 15:06:35 GMT

Sponsored Links
 I m creating my own widget...widget initial  layout contains one
button...when i click on that widget button it shud launch the
specified activity using service...everythng is working fine..but the
problem comes when there are 2 or more widget on home screen...when i
clicking on any one of them i m not able to specify with widget is
launching the activity...Please help???

Problem in identifying which widget click is launching the activity?

by Mark Murphy » Mon, 08 Jun 2009 19:39:52 GMT


Put the app-widget instance ID as an extra in the Intent you wrap with a
PendingIntent that associated with your button.

Mark Murphy (a Commons Guy)  | 

_Android Programming Tutorials_ Version 0.95 Available!


Sponsored Links

Other Threads

1. someone plz help me .. how to call built in camera app from my custom app ??

Do some debugging work...

The PackageManager can give you a list of all applications on your phone.
Step through them and find the Camera application and note the package name
of the camera application.

Assuming you have done that, you can do something similar to the following
(obviously putting in checks for the case the application doesn't exist,

String packageName = <package name found in above steps>;
PackageManager mgr = getPackageManager();
Intent intent = mgr.getLaunchIntentForPackage(packageName);

If the getLaunchIntentForPackage method returns null, as it sometimes does,
then you will have to create a new intent instead with something similar to
Intent intent = new Intent();
intent.setClassName(packageName, className);

I have not looked into how to find the className of an arbitrary application
but I'm sure with a little work you can figure it out.

I have already explained to you how to do this, both in these forums and
when you emailed me directly.  Rather than continually posting the same
question over and over and waiting for someone to do your coding for you and
give you complete functional code, I would suggest looking through the
developer guide and the SDK reference docs and trying to figure it out for


There are only 10 types of people in the world...
Those who know binary and those who don't.


2. Android Open-Source Project on devices

I think that its' a poor name choice for something that they don't  
want to be considered part of Android itself (especially as they like  
to claim they own the trademark, which is untrue in most of the world).

My guess it's an example of what happens when a marketing person gets  
to name an app without thinking about the bigger consequences.


* Looking for Android Apps? - Try *

Funky Android Limited is registered in England & Wales with the
company number  6741909. The registered head office is Kemp House,
152-160 City Road, London,  EC1V 2NX, UK.

The views expressed in this email are those of the author and not
necessarily those of Funky Android Limited, it's associates, or it's


3. File length is 0, which is not true... ?

4. How to find permissions required

5. Wallpapers for Android

6. GPS-Tracking application and telephone call

7. Cara rubah Magic jadi Hero