start acticity from widget


Last Updated:

  1. plusmoDroid

    plusmoDroid Member This Topic's Starter

    Joined:
    Mar 1, 2010
    Messages:
    6
    Likes Received:
    0
    I' m trying to launch an activity while clicking on the screen widget.
    I've found a way that the click on the screen widget launches the browser using pending intents.
    I've tried using something like this, but it doesn't work.
    Code (Text):
    1.  Intent defineIntent = new Intent(this,myActivityClass.class);
    2.                 PendingIntent pendingIntent = PendingIntent.getActivity(/*context,*/this,
    3.                         0 /* no requestCode */, defineIntent, 0 /* no flags */);
    4.                 updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent);
    Any ideas of what should I look for?
     

    Advertisement
  2. tdieckman

    tdieckman Well-Known Member

    Joined:
    Sep 30, 2009
    Messages:
    49
    Likes Received:
    5
    You need to pass a flag in the call to get the intent when starting an activity from a broadcast receiver like an app widget. Had this same problem a few weeks ago and while the docs for the flags are very obvious about having to pass one, you have to be looking at that part of the docs to see them.
     
    plusmoDroid likes this.
  3. plusmoDroid

    plusmoDroid Member This Topic's Starter

    Joined:
    Mar 1, 2010
    Messages:
    6
    Likes Received:
    0
    I searched the flags, and it worked!
    Thanks a lot for your help!
     

Share This Page

Loading...