android应用程序开关发送http帖子

时间:2016-12-11 09:24:27

标签: java android

我想向服务器发送HTTP客户端发布请求,但它一直显示错误。请帮我解决这个连接问题。我尝试遵循各种网站的在线指南,但仍会产生相同的错误。

错误:

  I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
  I/System.out: (HTTPLog)-Static: isShipBuild true
  I/System.out: (HTTPLog)-Thread-1-511220824: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
  I/System.out: (HTTPLog)-Thread-1-511220824: SMARTBONDING_FEATURE_ENABLED is false
  I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
  I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false

Java代码:

import android.app.Activity;
import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.Switch;

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.InputStream;

public class Tab2 extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab2);
        final String my_api_web_code ="yuhvttdxvy633642hhhghft90B24";

        Switch switch1 = (Switch)findViewById(R.id.switch1);
        switch1.setOnCheckedChangeListener(new        CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    try {
                        final InputStream is = new URL("https://www.teleduino.org/documentation/api/328-full?k=" + my_api_web_code + "&r=definePinMode&pin=2&mode=1").openStream();
                    } catch (Exception e) {
                    }
                } else {
                    try {
                        final InputStream is = new  URL("https://www.teleduino.org/documentation/api/328-full?k=" + my_api_web_code + "&r=definePinMode&pin=2&mode=0").openStream();
                    } catch (Exception e) {
                    }

                }
            }
        });


    }
}

的manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.kenny.mydroid">
    <uses-permission android:name="android.permisson."></uses-permission>
    <uses-permission android:name="android.permission.INTERNET" ></uses-   permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" ></uses-permission>>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" ></uses-permission>>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" ></uses-permission>>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission>>
    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Tab2"/>
    </application>

</manifest>

0 个答案:

没有答案