How to launch activity from android home screen widget
Posted
by Brian515
on Stack Overflow
See other posts from Stack Overflow
or by Brian515
Published on 2010-04-24T22:54:04Z
Indexed on
2010/04/24
23:03 UTC
Read the original article
Hit count: 660
Hi all,
I am desperately trying to get my head wrapped around how to implement home screen widgets. Right now, I (finally) was able to get a button on my widget respond to a button press setting up an intent filter in the manifest.
However, I cannot for the life of me figure out how to launch an activity when the button is pressed. Basically, here's the code i have:
@Override
public void onReceive(Context context, Intent intent)
{
super.onReceive(context, intent);
if(intent.getAction().equals("com.bic.search.searchWidget.CLICK"))
{
Toast.makeText(context, "It works!!", Toast.LENGTH_SHORT).show();
}
}
What I really want to do, though, is start a new activity, not display a toast message. I know it has something to do with pending intents, but I can't figure out how to get that to work.
Any help and sample code would be appreciated. Thanks a ton to whoever answers this!
© Stack Overflow or respective owner