I made a program to try to connect to a hosted database. But an error is occurring:
08-30 10: 42: 13.088 1710-1710 / genus.qrcodefinal E / log_tag: Error in http connection java.lang.SecurityException: Permission denied (missing INTERNET permission?)
Connection part:
Button botaoconecta = (Button) findViewById(R.id.botaoconecta);
botaoconecta.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("linkdosite**");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
}
});
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="genus.qrcodefinal">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>