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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:19:48+00:00 2026-06-10T20:19:48+00:00

I am trying to open a web browser window onclick of a button. My

  • 0

I am trying to open a web browser window onclick of a button.

My click event doesn’t appear to be getting called. LogCat shows no errors or any evidence of it being called. I have a feeling this is due to me having 2 methods named ‘onClick‘, but removing the second method causes an error. I can fix this error by making MainActivity abstract, but that crashes the app.

I feel this is a simple fix, but after pouring over documentation and several tutorials I cannot find the answer.

Code is below, followed by my manifest. Thanks in advance.

package com.spotsofmagic.spotsofmagic;

import android.app.Activity;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.widget.TextView;


public class MainActivity extends Activity implements OnClickListener {
    private static final String TAG = "Activity...";
    private NfcAdapter mAdapter;
    private TextView mTextView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);

        // grab our NFC Adapter
        mAdapter = NfcAdapter.getDefaultAdapter(this);

        // TextView that we'll use to output messages to screen
        mTextView = (TextView)findViewById(R.id.text_view);

        //displayMessage("Loading payload...");

    }

    private void displayMessage(String message) {
        mTextView.setText(message);
    }

    public void onClick(View v) {
        // TODO Auto-generated method stub
        // do something when the button is clicked
        displayMessage("Loading broswer");
        Uri uriUrl = Uri.parse("http://www.***.com/");      
        Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);  
        startActivity(launchBrowser);  

        if(v.getId() == R.id.btnVisitWebsite) {

        }
    }

    public void onClick(DialogInterface dialog, int which) {
        // TODO Auto-generated method stub

    }
}

And the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.spotsofmagic.spotsofmagic"
    android:versionCode="1"
    android:versionName="1.0" android:installLocation="auto">

    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.NFC" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-feature android:name="android.hardware.nfc" android:required="true" />

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

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

         <activity
            android:name=".CardActivity"
            android:label="@string/app_name" >

            <!-- Handle a collectable card NDEF record -->
            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
                <data android:mimeType="application/vnd.spotsofmagic.spotsofmagic"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </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-10T20:19:50+00:00Added an answer on June 10, 2026 at 8:19 pm

    You have an OnClickListener but you didn’t attach it to any button. Try

    ((Button) findViewById(R.id.your_button_id)).setOnClickListener(this);
    

    EDIT: The other problem is, that you implemented DialogInterface.OnClickListener instead of View.OnClickListener in your Activity.

    Remove the imports

    import android.content.DialogInterface;
    import android.content.DialogInterface.OnClickListener;
    

    And add

    import android.view.View.OnClickListener;
    

    You can also remove

    public void onClick(DialogInterface dialog, int which) {
        // TODO Auto-generated method stub
    
    }
    

    after this.

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

Sidebar

Related Questions

I'm trying to make a open source kiosk like system. When the web browser
I am trying to open a web browser with a supplied url, however, after
Hey guys, On my Xcode project, I am trying to open a web browser
Trying to figure out how to open the default browser from a click on
I need my web page to open a window and enable a disabled button
I'm trying to open the On Screen Keyboard from within a web application on
I am trying to implement a web service that uses open JPA to access
I'm trying to load a local web page executing: var html = document.open('google.html'); document.documentElement.innerHTML
I have an open wifi hotspot and a web server and I'm trying to
I am trying open a new window using url.Action. And the new Window url

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.