2

I am using Netbeans7.2 and entered uses-permission also but i have this error Java.net.Socket Exception Internet denied(Maybe missing internet permission )` my AndroidManifest file like this

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="importacao.dados" android:versionCode="1" android:versionName="1.0"> <application android:label="@string/app_name" > <activity android:name="importacao" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <uses-permission android:name="android.permission.INTERNET" /> </intent-filter> </activity> </application> </manifest> 

//Button

cliente.setOnClickListener(new Button.OnClickListener(){ public void onClick(View view){ InputStream is = null; ArrayList namevaluePairs = new ArrayList(); List r = new ArrayList(); try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost; httppost = new HttpPost("http://localhost/cliente.php"); httppost.setEntity(new UrlEncodedFormEntity(namevaluePairs)); HttpResponse response; response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); } catch(Exception e) { Toast.makeText(getBaseContext(),e.toString(),Toast.LENGTH_LONG).show(); } try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8")); StringBuilder sb = new StringBuilder(); String line = null; while((line=reader.readLine()) != null) { // }} catch(Exception e) { Log.e("Erro",e.toString()); }}}); 

1 Answer 1

6

Move your uses-permission tag to be outside the application tag. You also might need to add a uses-permission for android.permission.ACCESS_NETWORK_STATE, not sure how netbeans works.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="importacao.dados" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.INTERNET" /> <application android:label="@string/app_name" > 
Sign up to request clarification or add additional context in comments.

4 Comments

thanks my problem solved to doing this , sir i have another question my namevaluePairs showing me 0 items thats means do not populating data from Mysql db ? here is my php file code
<?php mysql_connect("localhost","root","abc"); mysql_select_db("fabricacao"); $sql=mysql_query("SELECT nome FROM cliente") ; $nome ='nome'; while($rows=mysql_fetch_assoc($sql)) { $output[]=$rows; print(json_encode($output)); } ?>
It's best to post a new question for that, keeps things clean.
Hi Ralgha! I have the same problem but my permission is in right place outside application tag, secondly i have added access_network_permission_state too. Any Help will be regarded

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.