Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7524667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:07:48+00:00 2026-05-30T03:07:48+00:00

I am developing an app widget that starts one activity which changes layout of

  • 0

I am developing an app widget that starts one activity which changes layout of the app widget… When I click it again I would like it to start another activity. It seems the general concensus is that you cannot set two listeners to the same button, but is there anyway around this? Can anyone give me some info on how to do this or get around it?

MyWidgetProvider.java

 public class MyWidgetProvider extends AppWidgetProvider 
 {

public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
public static String ACTION_WIDGET_CLICK = "ActionReceiverClick";




public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[]   appWidgetIds) {


    RemoteViews remoteViews = new RemoteViews( context.getPackageName(), R.layout.hellowidget_layout );

    Intent configIntent = new Intent(context, second_activity2.class);
    configIntent.setAction(ACTION_WIDGET_CONFIGURE);
    PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
    remoteViews.setOnClickPendingIntent(R.id.update, configPendingIntent);


    RemoteViews remoteViews1 = new RemoteViews( context.getPackageName(), R.layout.hellowidget_layout2 );

    configIntent = new Intent(context, second_activity3.class);
    configIntent.setAction(ACTION_WIDGET_CONFIGURE);
    configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
    remoteViews1.setOnClickPendingIntent(R.id.update2, configPendingIntent);

    appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); 
    appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); 

}
 }

and second_activity2.java

public class second_activity2 extends Activity
{


public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
@Override
public void onCreate( Bundle savedInstanceState ) 
{ 

    super.onCreate( savedInstanceState );
    setContentView( R.layout.main22 );
    getWindow().setWindowAnimations( 0 );


    Context context = this;
    AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.hellowidget_layout2);
    ComponentName thisWidget = new ComponentName(context, MyWidgetProvider.class);
    appWidgetManager.updateAppWidget(thisWidget, remoteViews);


    ComponentName locationReceiver1 = new ComponentName( second_activity2.this, SmsReceiver.class );
    PackageManager pm1 = getPackageManager();
    pm1.setComponentEnabledSetting( locationReceiver1, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP  );


    Toast toast = Toast.makeText( second_activity2.this, "Your incoming texts are now being blocked.", 3000 );
    toast.setGravity( Gravity.TOP, 0, 50 );
    toast.show();

     Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_HOME);
        this.startActivity(i);


};

}

Any help is greatly appreciated! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:07:49+00:00Added an answer on May 30, 2026 at 3:07 am

    I figured it out. While you can’t actually put another click listener on the same button, you can tell the intent to navigate to an activity that sets one up and then closes itself. As in this example:

    public class MyWidgetProvider extends AppWidgetProvider 
    {
    
    public static String ACTION_WIDGET_CONFIGURE = "ConfigureWidget";
    public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
    public static String ACTION_WIDGET_CLICK = "ActionReceiverClick";
    
    
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    
    
        RemoteViews remoteViews = new RemoteViews( context.getPackageName(), R.layout.hellowidget_layout );
        ComponentName thisWidget = new ComponentName(context, MyWidgetProvider.class);      
    
        Intent configIntent = new Intent(context, second_activity2.class);
        configIntent.setAction(ACTION_WIDGET_CONFIGURE);
        PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
        remoteViews.setOnClickPendingIntent(R.id.update, configPendingIntent);
    
    
        appWidgetManager.updateAppWidget(thisWidget, remoteViews);
    
    }
    }
    

    Then in second_activity2.class write this after onCreate()

    Context context = this;
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.hellowidget_layout2);
        ComponentName thisWidget = new ComponentName(context, MyWidgetProvider.class);
    
        Intent configIntent = new Intent(context, second_activity3.class);
        configIntent.setAction(ACTION_WIDGET_CONFIGURE);
        PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
        remoteViews.setOnClickPendingIntent(R.id.update2, configPendingIntent);
    
        appWidgetManager.updateAppWidget(thisWidget, remoteViews);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In short I'm developing a 'widget' in flash that I would like to implement
I am developing an android app which has a button in one activity and
When developing an app that will listen on a TCP/IP port, how should one
I am developing In App purchase for one existing application. Scenario is something like
I am developing an android app (only Widget) which displays some images from a
Greeting, I'm a C# programmer guy. I'm planning to start developing app for iphone
While developing my app I have come to realize that the majority of my
I'm considering developing an app for Google App Engine, which should not get too
i'm developing an app that make requests to the Musicbrainz webservice. I read in
I'm developing web app that user can save his/her work to server. The data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.