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

  • SEARCH
  • Home
  • 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 8560813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:21:46+00:00 2026-06-11T16:21:46+00:00

For me I have a button widget with a button that is just suppose

  • 0

For me I have a button widget with a button that is just suppose to launch a helloworld activity when I click it. I’ve tried following many posts online including this one, and yet the problem still there. I press the button, nothing happens. I am working on version 2.3 of android. Can someone point out what I am doing wrong?

My widget:

public class IconWidgetProvider extends AppWidgetProvider {

    @Override
    public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds) {
        final int N = appWidgetIds.length;

        for (int i=0; i<N; i++) {
            final Intent intent = new Intent(Intent.ACTION_MAIN, null);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            // first param is app package name, second is package.class of the main activity
            final ComponentName cn = new ComponentName("com.followup","com.followup.FollowUpActivity");
            intent.setComponent(cn);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            final PendingIntent myPI = PendingIntent.getActivity(context, 0, intent, 0);

            final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.icon_widget_layout);


            views.setOnClickPendingIntent(R.id.image_in_widget, myPI);

            final AppWidgetManager mgr = AppWidgetManager.getInstance(context);             mgr.updateAppWidget(cn, views);
        }
    }

}

homescreeniconinfo.xml

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="146dip"
    android:minHeight="72dip"
    android:updatePeriodMillis="0"
    android:initialLayout="@layout/icon_widget_layout"  >
</appwidget-provider>

icon_widget_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">


    <Button android:name="@+id/image_in_widget"
        android:contentDescription="@string/iconDescription"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight=".50"
        android:clickable="true"
        />

</LinearLayout>

mainifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.followup"
    android:versionCode="1"
    android:versionName="1.0" >
.
.
.
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    .
            .
            .
    <!-- Home icon widget -->
    <receiver android:name="IconWidgetProvider" 
              android:label="@string/app_name"
              android:icon="@drawable/ic_launcher">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
        <meta-data 
            android:name="android.appwidget.provider"
            android:resource="@xml/homescreeniconinfo" />
    </receiver>

        <activity
            android:name=".FollowUpActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>
  • 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-06-11T16:21:47+00:00Added an answer on June 11, 2026 at 4:21 pm

    Have you tried adding the event handler to your button?
    Perhaps I’m confused here as it’s been a while since I actually did some intense android programming, but from what I understand, this is what I’ve done to call an intent from another one in the past…

    <Button android:name="@+id/image_in_widget"
            android:contentDescription="@string/iconDescription"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".50"
            android:clickable="true"
            android:onClick="onClickFunction"
            />
    

    Paying extra attention to

    android:onClick="onClickFunction"
    

    Where “onClickFunction” would be a written method somewhere in your code that gets called when the button is clicked

    public void onClickFunction(View view){ 
        //stuff to do on click
    }
    

    EDIT
    This is ripped straight from the HelloWorld android tutorial which I have compiled and successfully run on my 2.3 Android Phone in the past
    this is the xml

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send"
        android:onClick="sendMessage" />
    

    this is in the main .java file

    /* called when the user clicks a button */
    public void sendMessage(View view)
    {
        Intent intent = new Intent(this, DisplayMessageActivity.class);
        EditText editText = (EditText)findViewById(R.id.edit_message);
        String message = editText.getText().toString();
        intent.putExtra(EXTRA_MESSAGE, message);
        startActivity(intent);
    }
    

    DisplayMessageActivity.class is the class that is essentially a new application (from your case I believe you want it to be a Hello World app)

    so you would make an XML for that called application and change/rewrite the DisplayMessageActivity class to do whatever “HelloWorld”-ey stuff you want…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I use GWT and I have a com.smartgwt.client.widgets.Button that has the following eventHandler:
I have a activity which has a button and 2 autocomplete widget. for the
Ok I have a simple main activity that just presents the user with a
I have a button widget that I had a successful rotation animation on but
I have an activity that has a VideoView widget that plays a mp4 file,
I have a widget that launches an activity, but when the activity finishes using
I have a GtkMenu Widget and i am adding it to screen on button
I have button that a user selects and I pop up a AlertDialog to
I have button in my application that opens android contact application for choose contact
I have button, which fires an event, that deletes a record from the database.

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.