如何解决否认,也许缺少的Internet权限许可? [英] How to resolve permission denied maybe missing internet permission?
本文介绍了如何解决否认,也许缺少的Internet权限许可?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Netbeans7.2并进入使用许可权也,但我有这个错误的java.net.Socket异常互联网否认(也许缺少互联网许可)`
我喜欢这个AndroidManifest文件
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=importacao.dados
安卓版code =1
机器人:=的versionName1.0>
<应用机器人:标签=@字符串/ APP_NAME>
<活动机器人:名字=IMPORTACAO
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
<使用许可权的android:NAME =android.permission.INTERNET对/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
< /清单>
//按钮
cliente.setOnClickListener(新Button.OnClickListener(){
公共无效的onClick(查看视图){
InputStream为= NULL;
ArrayList的namevaluepairs中=新的ArrayList();
列表R =新的ArrayList();
尝试{
HttpClient的HttpClient的=新DefaultHttpClient();
HttpPost httppost;
httppost =新HttpPost(HTTP://localhost/cliente.php);
httppost.setEntity(新UrlEn codedFormEntity(namevaluepairs中));
HTT presponse响应;
响应= httpclient.execute(httppost);
HttpEntity实体= response.getEntity();
是= entity.getContent();
}
赶上(例外五)
{
Toast.makeText(getBaseContext(),e.toString(),Toast.LENGTH_LONG).show();
}
尝试{
读者的BufferedReader =新的BufferedReader(新的InputStreamReader(是,UTF-8));
StringBuilder的SB =新的StringBuilder();
串线= NULL;
而((行= reader.readLine())!= NULL)
{
//
}}
赶上(例外五)
{
Log.e(ERRO,e.toString());
}}});
解决方案
将您的使用许可权的标签是应用程序标记之外。您可能还需要添加一个用途,权限android.permission.ACCESS_NETWORK_STATE,不知道如何Netbeans的作品。
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=importacao.dados
安卓版code =1
机器人:=的versionName1.0> <使用许可权的android:NAME =android.permission.INTERNET对/> <应用机器人:标签=@字符串/ APP_NAME>
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());
}}});
解决方案
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" >
这篇关于如何解决否认,也许缺少的Internet权限许可?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文