Android NullPointerException using AsyncTask
===

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?



    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)


    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) {
            			// 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;
        }
    
        
    }





