【问题标题】:How to resolve permission denied maybe missing internet permission?如何解决权限被拒绝可能缺少互联网权限?
【发布时间】:2012-10-16 19:48:30
【问题描述】:

我正在使用 Netbeans7.2 并输入了使用权限,但我有这个错误 Java.net.Socket Exception Internet denied(可能缺少 Internet 权限)` 我的 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());
    }}});

【问题讨论】:

    标签: android android-manifest android-permissions


    【解决方案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" >
    

    【讨论】:

    • 感谢我的问题解决了这样做,先生,我还有另一个问题,我的 namevaluePairs 向我显示 0 个项目,这意味着不从 Mysql db 填充数据?这是我的php文件代码
    • 最好为此发布一个新问题,保持干净。
    • 嗨,拉尔加!我有同样的问题,但我的权限在应用程序标签之外的正确位置,其次我也添加了 access_network_permission_state。任何帮助都将被视为
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2015-08-15
    • 1970-01-01
    • 2021-05-24
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    相关资源
    最近更新 更多