2

私は Netbeans7.2 を使用していて、uses-permission も入力しましたが、このエラーが発生しました Java.net.Socket Exception Internet denied(Maybe missing internet permission )` 私の 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());
    }}});
4

1 に答える 1

6

uses-permission タグを application タグの外に移動します。android.permission.ACCESS_NETWORK_STATE に uses-permission を追加する必要があるかもしれませんが、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" >
于 2012-10-16T19:50:21.500 に答える