如何解决否认,也许缺少的Internet权限许可?(How to resolve permissio

2019-09-24 04:50发布

我使用Netbeans7.2并进入使用许可权也,但我有这个错误的java.net.Socket异常互联网否认(也许缺少互联网许可)这样`我AndroidManifest文件

  <?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> 

//按钮

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());
    }}});

Answer 1:

将您的使用,许可标记,是应用程序标记之外。 您可能还需要添加一个用途,权限android.permission.ACCESS_NETWORK_STATE,不知道如何Netbeans的作品。

<?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" >


文章来源: How to resolve permission denied maybe missing internet permission?