Click here to Skip to main content
15,889,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi guys .
when i run my app i get an unusual Error in LogCat
Error opening trace file: No such file or directory (2)
im trying to make a program to connect Internet

i added this tag to Manifest File
manifest :
HTML
<uses-permission android:name="android.permission.INTERNET"/>


my java :
Java
package net.learn2develop.http1;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import android.util.Log;

public class MainActivity extends Activity {

	private InputStream OpenHttpConnection(String urlString) throws IOException
	{
		Log.d("Location:","Method-first Line");
		InputStream in=null;
		int response=-1;
		URL url=new URL(urlString);
		//URL url=new URL(urlString);
		URLConnection conn=url.openConnection();
		if(!(conn instanceof HttpURLConnection))
			throw new IOException("Not an Http connection");
		try
		{
			Log.d("Locataion:","try bloc");
			HttpURLConnection httpConn=(HttpURLConnection) conn;
			httpConn.setAllowUserInteraction(false);
			httpConn.setFollowRedirects(true);
			httpConn.setRequestMethod("GET");
			httpConn.connect();
			response=httpConn.getResponseCode();
			if(response==HttpURLConnection.HTTP_OK){
				in=httpConn.getInputStream();
			}
		}
		catch(Exception ex)
		{
			Log.d("Networking",ex.getLocalizedMessage());
			throw new IOException("Error connecting");
		}	
		return in;
			}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	

}


any help ?
Posted
Updated 24-Nov-14 8:14am
v2

1 solution

Make a point the every time this code

C++
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
   }


Comes before all your code in the MainActivity class
it met also cause you some problems.

Try it.
 
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