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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:12:19+00:00 2026-06-08T03:12:19+00:00

I’m trying to do what should be a simple post to a website and

  • 0

I’m trying to do what should be a simple post to a website and receive a response but I am having problems with implementing AsyncTask to supply the required secondary stream. Currently I am getting a java.lang.NullPointerException. Any ideas what’s causing this?

Logcat:

07-18 11:34:14.829: E/AndroidRuntime(8354): FATAL EXCEPTION: main
07-18 11:34:14.829: E/AndroidRuntime(8354): java.lang.NullPointerException
07-18 11:34:14.829: E/AndroidRuntime(8354):     at ca.waddlesoft.smpclient_android.MainActivity$SmpProcessor.onPostExecute(MainActivity.java:50)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at ca.waddlesoft.smpclient_android.MainActivity$SmpProcessor.onPostExecute(MainActivity.java:1)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.os.AsyncTask.finish(AsyncTask.java:602)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.os.AsyncTask.access$600(AsyncTask.java:156)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.os.Looper.loop(Looper.java:137)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at android.app.ActivityThread.main(ActivityThread.java:4514)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at java.lang.reflect.Method.invoke(Method.java:511)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
07-18 11:34:14.829: E/AndroidRuntime(8354):     at dalvik.system.NativeStart.main(Native Method)

My Code:

package ca.waddlesoft.smpclient_android;

import java.net.MalformedURLException;
import java.net.URL;

import ca.waddlesoft.smpclient_android.R;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {
    private TextView tv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv;
        tv = (TextView)findViewById(R.id.TextView01);
        setContentView(R.layout.activity_main);
        SmpProcessor task = new SmpProcessor();
        task.execute();
    }

    private class SmpProcessor extends AsyncTask <Void,Void,String> {
        @Override
        protected String doInBackground(Void... voids){
        URL url = null;
        try {
            url = new URL("http://secure.g4apps.com");
            String app="A1";
            String data = "E1,E1,AT333AT333,9055627513,2012-02-02 02:02:02,2012-02-02 02:02:02,-454545.343434,434343.232323,A334A334A334A443X,1000000,3434";
            byte [] databyte=data.getBytes();
            String out = SmpClass.smpCall(url,app,data);
            //  String out = new String(smpresponse);
            return out;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String result) {
        tv.setText(result);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
  • 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-08T03:12:21+00:00Added an answer on June 8, 2026 at 3:12 am

    2 mistakes:

    • You declare your textView locally + in your class. Just declare it in
      your class.
    • You initialize your textView before calling setContentView

    Try this:

    package ca.waddlesoft.smpclient_android;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import ca.waddlesoft.smpclient_android.R;
    
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.TextView;
    import android.support.v4.app.NavUtils;
    
    public class MainActivity extends Activity {
        private TextView tv;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tv = (TextView)findViewById(R.id.TextView01);
    
            SmpProcessor task = new SmpProcessor();
            task.execute();
        }
    
      private class SmpProcessor extends AsyncTask <Void,Void,String> {
    
                @Override
                protected String doInBackground(Void... voids){
                    URL url = null;
                    try {
                        url = new URL("http://secure.g4apps.com");
                        String app="A1";
                        String data = "E1,E1,AT333AT333,9055627513,2012-02-02 02:02:02,2012-02-02 02:02:02,-454545.343434,434343.232323,A334A334A334A443X,1000000,3434";
    //                  byte [] databyte=data.getBytes();
                        String out = SmpClass.smpCall(url,app,data);
    //                  String out = new String(smpresponse);
                        return out;
                    } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    return null;
                }
                @Override
                protected void onPostExecute(String result) {
                        tv.setText(result);
                }
            }
    
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.