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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:22:52+00:00 2026-06-12T12:22:52+00:00

public void onClick(View v) { fun_demo(); Intent myIntent = new Intent(v.getContext(), Activity1.class); startActivityForResult(myIntent, 0);

  • 0
   public void onClick(View v)
    {
        fun_demo();
        Intent myIntent = new Intent(v.getContext(), Activity1.class);
        startActivityForResult(myIntent, 0); 
    }

Assume the above the function “fun_demo()” is going to return some values on the same screen through a textview,when clicking button from the same screen.

Here my need is to display that returnable values on screen number two.So i have added these lines to my firstscreen.java

Intent myIntent = new Intent(v.getContext(), Activity1.class);
        startActivityForResult(myIntent, 0); 

in the function fun_demo().Is this code right?

NOTE: fun_demo()’s code is written on the screen one.

FirstscreensActivity.java for reference

package com.android.button.web;

import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import android.app.*;
import android.content.Intent;
import android.os.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Tesing_webserviceActivity extends Activity {
/** Called when the activity is first created. */

private static final String NAMESPACE = "http://tempuri.org/";
private static final String METHOD_NAME = "HelloWorld";
private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static final String URL = "http://122.248.240.105:93/Student.asmx?WSDL";
TextView tv;

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

    tv=(TextView)findViewById(R.id.textView_222);

    Button btn = (Button)findViewById(R.id.but);
    btn.setOnClickListener(btnListener);
}

public void fun_demo()
{
        TextView tv = (TextView) findViewById(R.id.textView_222);
    try
    {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("str","");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION,envelope);
    Object result = envelope.getResponse();
    System.out.println("Result : " + result.toString());
    ((TextView) findViewById (R.id.textView_222)).setText(""+result.toString());
    } catch (Exception E) {
    E.printStackTrace();
    ((TextView) findViewById (R.id.textView_222)).setText("ERROR:"    + E.getClass().getName() + ":" + E.getMessage());
    }     }  

private OnClickListener btnListener = new OnClickListener()
{
    public void onClick(View v)
    {
        fun_demo();
        Intent myIntent = new Intent(v.getContext(), Activity1.class);
        startActivityForResult(myIntent, 0); 
    }
  };
}

This concept is actually going to consume a web service on android eclipse

Here is my logcat for reference.

LOGCAT

05-29 18:22:04.455: W/System.err(1300):     at android.os.Looper.loop(Looper.java:123)
05-29 18:22:04.465: W/System.err(1300):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-29 18:22:04.465: W/System.err(1300):     at java.lang.reflect.Method.invokeNative(Native Method)
05-29 18:22:04.465: W/System.err(1300):     at java.lang.reflect.Method.invoke(Method.java:521)
05-29 18:22:04.465: W/System.err(1300):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-29 18:22:04.465: W/System.err(1300):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-29 18:22:04.465: W/System.err(1300):     at dalvik.system.NativeStart.main(Native Method)
05-29 18:22:04.465: D/AndroidRuntime(1300): Shutting down VM
05-29 18:22:04.465: W/dalvikvm(1300): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-29 18:22:04.476: E/AndroidRuntime(1300): FATAL EXCEPTION: main
05-29 18:22:04.476: E/AndroidRuntime(1300): java.lang.NullPointerException
05-29 18:22:04.476: E/AndroidRuntime(1300):     at com.android.button.web.Tesing_webserviceActivity.CallWebService(Tesing_webserviceActivity.java:55)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at com.android.button.web.Tesing_webserviceActivity$1.onClick(Tesing_webserviceActivity.java:62)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.view.View.performClick(View.java:2408)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.view.View$PerformClick.run(View.java:8816)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.os.Handler.handleCallback(Handler.java:587)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.os.Handler.dispatchMessage(Handler.java:92)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.os.Looper.loop(Looper.java:123)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at java.lang.reflect.Method.invokeNative(Native Method)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at java.lang.reflect.Method.invoke(Method.java:521)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-29 18:22:04.476: E/AndroidRuntime(1300):     at dalvik.system.NativeStart.main(Native Method)

Thanks a lot!..

  • 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-12T12:22:53+00:00Added an answer on June 12, 2026 at 12:22 pm

    Intent myIntent = new Intent(v.getContext(), Activity1.class);

    this line creating a problem due not initialization of activity

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

Sidebar

Related Questions

btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent i = new Intent(this,DetailEventActivity.class); //
public void onClick(View v) { Intent chapter; chapter = new Intent(c.theworld.com.nikhil.CHAPTER); switch (v.getId()) {
Button novice = (Button) findViewById(R.id.novice); novice.setOnClickListener(new OnClickListener(){ public void onClick(View v) { Intent nov
Code: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // fileReader(); new xyz().execute(); }//
button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { db.update(); } }); On line
public Class GUi(){ // More Code public void onClick(ClickEvent event) { LoginServer loginServer =new
public void openOptions() { Intent intent=new Intent(this,Game.class); //intent.putExtra(razmer, level); startActivity(intent); // Intent intent=new Intent(this,Options.class);
Lets say that I have this code moveDirectory.setOnClickListener(new OnClickListener(){ public void onClick(View v) {
This is my current code: public void onClick(View v) { final Intent pickIntent =
button3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub

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.