tags:

views:

16

answers:

1

I want to do some calculating after touch-Event on my widget. Is there a possibility to do this without starting an activity? My problem is that i have to register an onClickPendingIntent to the touch-action....

There is an annoying visual response with my solution: screen flashes to black and reappears to homescreen.

this is in the widget-provider:

Intent doit_intent = new Intent(context, DoItActivity.class);
PendingIntent pendingIntent = 
           PendingIntent.getActivity(context,0, doit_intent, 0);
remoteView.setOnClickPendingIntent(R.id.main_widget, pendingIntent);

DoItActivity.class

public class DoItActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //do some static function calls

    finish();
  }
}
+1  A: 

Use a PendingIntent that does not start an activity, then. Use getService() or getBroadcast() instead of getActivity().

CommonsWare
you made my day!
joki