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 5988979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:02:07+00:00 2026-05-22T23:02:07+00:00

So I have been trying for hours to get this to work and I

  • 0

So I have been trying for hours to get this to work and I can’t for the life of me figure it out. I have tried many different ideas I’ve found just googling it, but without any luck. I am trying to create an android widget that you can click on an image and it uses the default browser to open up a website. I am able to get the image and widget working correctly, but when I try to implement the code for the button to open a website, it kills the widget and says “Problem loading gadget” on the phone. I’m fairly new to making widgets/apps so any advice is appreciated.
How can I make the widget work?

Here is my code:

Main.xml

$<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/widget_frame_portrait"
>
    <TextView android:id="@+id/xmas"
        android:layout_toRightOf="@+id/refresh"
        android:layout_width="wrap_content"
        android:layout_height="50dip"
        android:text="@string/hello"
        android:layout_marginTop="37dip"
        android:layout_marginBottom="25dip"

        android:layout_marginRight="5dip"

        android:orientation="vertical"
        android:textColor="#000000"/>

    <ImageButton
        android:layout_height="50dip"
        android:id="@+id/refresh"
        android:background="@drawable/feep"
        android:layout_width="225dip"
        android:layout_marginTop="25dip"
        android:layout_marginBottom="25dip"
        android:layout_marginLeft="25dip"
        android:layout_marginRight="1dip"
        android:orientation="horizontal"

        android:clickable="true"
        android:onClick="openWebUrl"
    />
</RelativeLayout>

My only activity called bGiving.Java:

$package chris.days.to;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.Button;

public class bGiving extends Activity implements View.OnClickListener  {

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

    }

    public void openWebURL(View v) {
        String url = "http://google.com";

        Intent i = new Intent(Intent.ACTION_VIEW);

        i.setData(Uri.parse(url));

        startActivity(i);
    }

    public void onClick(View v) {

    }
}

and my Android Manifest is:

    $<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="chris.days.to"
      android:versionCode="1"
      android:versionName="1.0">
        <uses-sdk android:minSdkVersion="4" />

        <application android:icon="@drawable/icon" android:label="@string/app_name">

            <receiver android:name=".DaysToXmas" android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                </intent-filter>
                <meta-data android:name="android.appwidget.provider"
                           android:resource="@xml/hello_widget_provider" />
            </receiver>

            <activity android:name=".bGiving"
                      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>

When I add in the code in the main.xml “android:onClick=”openWebUrl” it kills the widget.

  • 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-22T23:02:09+00:00Added an answer on May 22, 2026 at 11:02 pm

    Set a PendingIntent to your Button. This will cause the Intent to be executed when the Button is pressed.

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(data);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        remoteView.setOnClickPendingIntent(R.id.button, pendingIntent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is crazy, I have been trying for hours to get this to work.
I have been scratching my head for hours trying to figure out why this
I have been banging my head for hours trying to figure out why this
I've been trying to figure this out for hours, there are many similar topics
I have been trying for too many hours now myself and can't get the
I'm a rails beginner and have been several hours now trying to figure out
I've spent many hours trying to get this to work. And I'm getting quite
I've been trying to get this code to work for a few hours now
I've been trying to get this code to work for hours! All I need
I have been looking around for a few hours trying to figure out how

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.