Click here to Skip to main content
15,887,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am using this code but it gives errors i am unable to trace.Any help would be appreciated.Here is the code:


Java
package com.example.test;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;



public class MainActivity extends Activity {
	
	TextView display;

	private MyDatagramReceiver myDatagramReceiver = null;
	
	
	protected void onResume() {
	    myDatagramReceiver = new MyDatagramReceiver();
	 
	   myDatagramReceiver.start();
	  
	}
	

	protected void onPause() {
	  //  myDatagramReceiver.kill();
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		display=(TextView) findViewById(R.id.textView1);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		
		
		return true;
	}

	private class MyDatagramReceiver extends Thread {
	    private boolean bKeepRunning = true;
	    private String lastMessage = "";

	    public void run() {
	        String message;
	        byte[] lmessage = new byte[100];
	        

	        try {
	            DatagramSocket socket = new DatagramSocket(2690);
	            Log.v("Run", "Socket Created");
	            while(bKeepRunning) {
	            	DatagramPacket packet = new DatagramPacket(lmessage, lmessage.length);
	                socket.receive(packet);
	                message = new String(lmessage, 0, packet.getLength());
	                lastMessage = message;
	                runOnUiThread(updateTextMessage);
	                Log.v("Receiving", "packet recvd");
	            }
	            
	            if (socket != null) {
	 	           socket.close();
	 	          Log.v("SOC", "Socket closed");
	 	       }
	        } catch (Throwable e) {
	            e.printStackTrace();
	        }

	       
	    }

	    public void kill() { 
	        bKeepRunning = false;
	    }

	    public String getLastMessage() {
	        return lastMessage;
	    }
	}

	private Runnable updateTextMessage = new Runnable() {
	    public void run() {
	        if (myDatagramReceiver == null) return;
	        display.setText(myDatagramReceiver.getLastMessage());
	    }
	};
	
}


Following are the errors:

11-14 03:04:06.240: E/AndroidRuntime(881): FATAL EXCEPTION: main
11-14 03:04:06.240: E/AndroidRuntime(881): Process: com.example.test, PID: 881
11-14 03:04:06.240: E/AndroidRuntime(881): java.lang.RuntimeException: Unable to resume activity {com.example.test/com.example.test.MainActivity}: android.util.SuperNotCalledException: Activity {com.example.test/com.example.test.MainActivity} did not call through to super.onResume()
11-14 03:04:06.240: E/AndroidRuntime(881): java.lang.RuntimeException: Unable to resume activity {com.example.test/com.example.test.MainActivity}: android.util.SuperNotCalledException: Activity {com.example.test/com.example.test.MainActivity} did not call through to super.onResume()
11-14 03:04:06.240: E/AndroidRuntime(881): Caused by: android.util.SuperNotCalledException: Activity {com.example.test/com.example.test.MainActivity} did not call through to super.onResume()












Thanks
Posted
Updated 13-Nov-14 21:27pm
v2

1 solution

The error message
did not call through to super.onResume()

tells you exactly what is wrong. See also http://developer.android.com/training/basics/activity-lifecycle/pausing.html[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900