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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:50:12+00:00 2026-06-13T13:50:12+00:00

I write this code in Main.java class but the program not run. Why? the

  • 0

I write this code in Main.java class but the program not run. Why? the program has error of Intent i=new Intent(this,Location.class); what is the problem??

package org.example.loyaltier;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.content.Intent;

public class Main extends Activity {

private WebView mWebView;
private Button mHome;
private Button mProduct;
private Button mPlaces;

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

    mWebView = (WebView)findViewById(R.id.web_view);

    mHome = (Button)findViewById(R.id.button_home);
    mProduct=(Button)findViewById(R.id.button_product);
    mPlaces=(Button)findViewById(R.id.button_places);

    mHome.setOnClickListener(onClickListener);


}
private OnClickListener onClickListener=new OnClickListener(){
    public void onClick(View v){
        switch(v.getId()){
        case R.id.button_home:
            mWebView.loadUrl      ("http://loyaltier.com/app/mobile/code/home/home.php");
            break;
        case R.id.button_product:
            mWebView.loadUrl("http://loyaltier.com/app/mobile/design/catalog/catalog1.php");
            break;
        case R.id.button_places:
            Intent i=new Intent(this,Location.class);
            startActivity(i);
            break;
        }
    }
};
}

The problems is : The constructor Intent(new View.OnClickListener(){}, Class<Location>) is undefined but i don’t understand what is the problem and how can I solve this?

Please help me fast 😉

LogCat::

10-31 11:35:04.135: D/AndroidRuntime(16626): Shutting down VM
10-31 11:35:04.135: W/dalvikvm(16626): threadid=1: thread exiting with uncaught exception (group=0x40a3e1f8)
10-31 11:35:04.159: E/AndroidRuntime(16626): FATAL EXCEPTION: main
10-31 11:35:04.159: E/AndroidRuntime(16626): java.lang.IllegalStateException: Could not find a method Places(View) in the activity class org.example.loyaltier.Main for onClick handler on view class android.widget.Button with id 'button_places'
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.view.View$1.onClick(View.java:3026)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.view.View.performClick(View.java:3480)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.view.View$PerformClick.run(View.java:13983)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.os.Handler.handleCallback(Handler.java:605)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.os.Looper.loop(Looper.java:137)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.app.ActivityThread.main(ActivityThread.java:4340)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at java.lang.reflect.Method.invokeNative(Native Method)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at java.lang.reflect.Method.invoke(Method.java:511)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at dalvik.system.NativeStart.main(Native Method)
10-31 11:35:04.159: E/AndroidRuntime(16626): Caused by: java.lang.NoSuchMethodException: Places [class android.view.View]
10-31 11:35:04.159: E/AndroidRuntime(16626):    at java.lang.Class.getConstructorOrMethod(Class.java:460)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at java.lang.Class.getMethod(Class.java:915)
10-31 11:35:04.159: E/AndroidRuntime(16626):    at android.view.View$1.onClick(View.java:3019)
10-31 11:35:04.159: E/AndroidRuntime(16626):    ... 11 more
10-31 11:35:04.190: D/dalvikvm(16626): GC_CONCURRENT freed 212K, 3% free 14282K/14599K, paused 2ms+2ms
10-31 11:35:09.057: I/Process(16626): Sending signal. PID: 16626 SIG: 9
  • 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-13T13:50:13+00:00Added an answer on June 13, 2026 at 1:50 pm

    The this in the new Intent(this,Location.class); refers to the instance of the anonymous View.OnClickListener object. You need to supply an instance of the Context. Try:

    Intent i=new Intent(Main.this,Location.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i write this code in main.java ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); try{ HttpClient httpclient
I have write this code but it does work only if I am already
I've write this code to add textview into table row, but I've problem for
This is homework, not going to lie. I need to write a program which
I am new to java and netbeans. I am trying to write a program
for an assignment in my Java class I'm supposed to write a program for
This is my .java code public class MainHelp extends PreferenceActivity { @Override public void
My class assignment is to write a program that has the user input a
I'm trying to write a Java program that will run an OpenOffice Macro. I'm
I wrote this tiny code: #include <stdio.h> int main() { size_t temp; temp =

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.