1. Are you ready for the Galaxy S20? Here is everything we know so far!

Unable to launch an activity from an AppWidget

Discussion in 'Android Development' started by kswebd, May 19, 2011.

  1. kswebd

    kswebd Lurker
    Thread Starter

    I have this code setup in my app widget and I have listed the activity it should launch below. I can't for the life of me get the activity to launch when the button is clicked. Nothing happens when I click on it.


    public class MyAppWidget extends AppWidgetProvider
    {
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
    {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);

    Intent intent = new Intent(context, EditActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
    remoteViews.setOnClickPendingIntent(R.id.btnEditConfiguration, pendingIntent);

    appWidgetManager.updateAppWidget(thisWidget, remoteViews);
    }
    }

    public class EditActivity extends Activity
    {
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.configure);
    }
    }
     



    1. Download the Forums for Android™ app!


      Download

       
  2. uaeHamed

    uaeHamed Newbie

    Did you modify the manifest?
     
Loading...
Similar Threads - Unable launch activity
  1. Rhemsuda
    Replies:
    2
    Views:
    224
  2. King Mustard
    Replies:
    2
    Views:
    284
  3. 血刃战神
    Replies:
    3
    Views:
    390
  4. riyas21
    Replies:
    3
    Views:
    286
  5. Sindhi Apps
    Replies:
    0
    Views:
    439
  6. Bitterend
    Replies:
    4
    Views:
    607
  7. EnthusiasticMalfunction
    Replies:
    2
    Views:
    360
  8. rhstar
    Replies:
    1
    Views:
    704
  9. Antarmanu71
    Replies:
    2
    Views:
    1,259
  10. adityaagrawal167
    Replies:
    0
    Views:
    433

Share This Page

Loading...