Guys i want to recieve values from MySQL into my app without using buttons. I have used wampserver for the connection. I then followed this tutorial for both, create the php file and to code in android studio: https://www.youtube.com/watch?v=38HDyEUEpCw
but, the following code has deprecated parts:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://10.0.2.2/folder/getAllSensors.php");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
inputStream = httpEntity.getContent();
So, i refered this link: HttpEntity is deprecated on Android now, what's the alternative?
and with it i coded this:
public class LoginActivity extends Activity {
TextView textElement;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
StrictMode.enableDefaults();
textElement = (TextView) findViewById(R.id.textView);
getData();
}