Pending intent not detecting onCreate

by » Wed, 29 Apr 2009 08:19:21 GMT

Sponsored Links
 I have the following code in a static function in my application

                Intent defineIntent = new Intent(context,
                PendingIntent pendingIntent = PendingIntent
                                .getActivity(context, 0, defineIntent, 0);

                views.setOnClickPendingIntent(, pendingIntent);

                // Tell the widget manager
                appWidgetManager.updateAppWidget(appWidgetId, views);

custom activity's based on user clicks on your widgets. However even
though Logcat says Starting Activity: Intent {......} my activities on
create function never gets called!

Note my Activity is as follows:

public class ToggleIntentActivity extends Activity {
        protected void onCreate(Bundle savedInstanceState) {
                Log.e(QuickerCutWidgetManager.TAG, "On create");

Any ideas?

Pending intent not detecting onCreate

by » Wed, 29 Apr 2009 08:52:16 GMT

 As a side note I also tried using LayoutInflator and attaching an
onClickListener to the imageview manually, but that failed to
recognise any events. Im guessing here that changes made via a
layoutinflator will not be picked up by remote views which later use
that layout?

On Apr 29, 1:19am, ""


Sponsored Links

Pending intent not detecting onCreate

by Jeff Sharkey » Wed, 29 Apr 2009 11:41:27 GMT

 Hmm, not sure exactly why it isn't working.  Because you can't know
the state of the remote AppWidgetHostView holding your widget, you
should package up all operations each time you push an update.  You
said in logcat it looks like it's trying to start the activity, could
you paste the couple of lines surrounding that?

Also, if you don't have an <intent-filter> inside the Activity
definition in your manifest, you might need to add the
android:exported="true" flag.


On Tue, Apr 28, 2009 at 5:52 PM,

Jeff Sharkey


Pending intent not detecting onCreate

by » Wed, 29 Apr 2009 18:40:36 GMT

 hanks for your reply Jeff,

Turns out what I really needed to do here was learn how Intent based
programming on Android works and how to actually implement it! What I
was missing here was actually declaring the activity in the Android
XML (I assumed that activities only had to be declared if they were
actually going to display something).

Still though I would be really nice if I could get direct access to
Button Widgets via LayerInflator so that I can directly manipulate the
background of the button, unfortunately the following seems to have no

LayoutInflater inflater = (LayoutInflater) context

View view = inflater.inflate(R.layout.widget_layout, null);

Button button = (Button) view.findViewById(;

RemoteViews views = new RemoteViews(context.getPackageName(),

Intent defineIntent = new Intent(context, ToggleActivity.class);
defineIntent.putExtra("toggle", toggle);
PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0,
defineIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

views.setOnClickPendingIntent(, pendingIntent);

// Tell the widget manager
appWidgetManager.updateAppWidget(appWidgetId, views);

No big deal tho since I can always use an ImageView and call

On Apr 29, 4:25am, Jeff Sharkey <> wrote:

Pending intent not detecting onCreate

by Jeff Sharkey » Thu, 30 Apr 2009 03:45:25 GMT

 ight, that wouldn't have an effect because your inflated layout is a
completely different copy from the one inflated by the home screen.

Also, I noticed that your using "putExtra" in your PendingIntents. Be
sure to use the FLAG_CANCEL_CURRENT flag when calling getActivity() to
make sure your extras are updated correctly. And be aware that you
can only have one set of extras for any given PendingIntent
action+data+category+component pair.

If you're trying to change the background of a button, you could use
this slightly-hacky approach: set the button background to a leveled
drawable, and then use setDrawableParameters() to change the level and
show the desired background.

You'd probably want to keep the number of layers to a minimum to keep it speedy.


On Wed, Apr 29, 2009 at 3:40 AM,
<> wrote:

Jeff Sharkey


Pending intent not detecting onCreate

by » Thu, 30 Apr 2009 05:31:13 GMT

 hanks for your help Jeff, its finally starting to make a lot more
sense now!


On Apr 29, 6:43pm, Jeff Sharkey <> wrote:

Other Threads

1. Problem with AnimationDrawable


I have problems with AnimationDrawable which i use to animate a
'striped' gif file. In fact I have two animations that I want to use
in one activity (and they must be used in the same activity). Both
animation are build with 7 frames :

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="
 android:id="@+id/analyse" android:oneshot="false">
 <item android:drawable="@drawable/analyse_frame_0"
android:duration="50" />
 <item android:drawable="@drawable/analyse_frame_1"
android:duration="50" />
<item android:drawable="@drawable/analyse_frame_2"
android:duration="50" />
 <item android:drawable="@drawable/analyse_frame_3"
android:duration="50" />
<item android:drawable="@drawable/analyse_frame_4"
android:duration="50" />
 <item android:drawable="@drawable/analyse_frame_5"
android:duration="50" />
<item android:drawable="@drawable/analyse_frame_6"
android:duration="50" />

The second one is the same, just different files but also 7 frames.

In the onCrate() method of my activity I start the first animation and
launch a 15 second timer (the idea is that the first animation is
playing when the timer ticks). I use the following code:

      //The onCreate method of the activity class.
      public void onCreate(Bundle savedInstanceState) {

                      layout =
                      analyseImage = (ImageView)

                      analyseAnimation = (AnimationDrawable)

                      MyCount counter = new MyCount(15000,1000);.

Unfortunately this does not work. However when the timer finishes I
want to start a second animation and launch a seperate thread. And
this works - when I start the animation in the 'onFinish' method of
the timer, the animation starts properly:

   //the onFinish() method of timer.
      public void onFinish()

analyseImage .destroyDrawingCache();
analyseImage .setVisibility(View.GONE);

                                      connectImage = (ImageView)
                                      connectAnimation =
(AnimationDrawable) analyseImage.getBackground();

Unfortunately this does not work so good because it only works when I
comment-out the first one - otherwise I get an Exception :
'OutOfMemoryError: bitmap size exceeds VM budget'. As you see I try to
release some memory but this does not help. This is a crucial problem,
since my application is working in a 'ring' of couple activities. So
when I finish the last one it goes back to the first one - it is
possible that the activity with animations will be called many times
in the life-time of the whole app. So I need to release the memory
from the second one as well.

So now here are my questions:
- why can't I start the first animation instantly after the activity
starts and how to do this?
- How to release the memory from the animations?

Can anyone please help?

PS: I am working on Android 1.5


2. mms video streaming

how to make a video streaming with mms in android?
i have problem to do that . . .

Mobile Developer
mobile :
email :
blog :


3. [paging galaxy 5 user] firmware asia

4. what to do with Only the original thread that created a view hierarchy can touch its views?

5. Mixing kernel versions.

6. How to use Linux capabilities, i.e. cap_get_proc, cap_to_text

7. How to compile kernel for Android V irtual Device 锛