Skip to content

Instantly share code, notes, and snippets.

View survivingwithandroid's full-sized avatar

Surviving with android (by Francesco Azzola) survivingwithandroid

View GitHub Profile
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
void loop() {
EthernetClient client = server.available(); // Is there a client (Our Android smartphone)
// Read temp
int sensorVal = analogRead(3);
float vSens = (sensorVal /1024.0) * 5.0;
//Serial.println(vSens);
float temp = (vSens - 0.5) * 100;
<proxy name="AndroidService"
transports="https http"
startOnLoad="true"
trace="disable"
statistics="enable">
<description/>
<target>
<inSequence>
<log>
<property name="Message Flow" value="Arduino API"/>
private void getWeather() {
weatherclient.getCurrentCondition(new WeatherRequest(currentCity.getId()),
new WeatherClient.WeatherEventListener() {
@Override
public void onWeatherRetrieved(CurrentWeather currentWeather) {
// We have the current weather now
// Update subtitle toolbar
toolbar.setSubtitle(currentWeather.weather.currentCondition.getDescr());
tempView.setText(String.format("%.0f",currentWeather.weather.temperature.getTemp()));
pressView.setText(String.valueOf(currentWeather.weather.currentCondition.getPressure()));
private void getWeather() {
weatherclient.getCurrentCondition(new WeatherRequest(currentCity.getId()),
new WeatherClient.WeatherEventListener() {
@Override
public void onWeatherRetrieved(CurrentWeather currentWeather) {
// We have the current weather now
// Update subtitle toolbar
toolbar.setSubtitle(currentWeather.weather.currentCondition.getDescr());
tempView.setText(String.format("%.0f",currentWeather.weather.temperature.getTemp()));
pressView.setText(String.valueOf(currentWeather.weather.currentCondition.getPressure()));
private Dialog createDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View v = inflater.inflate(R.layout.select_city_dialog, null);
builder.setView(v);
EditText et = (EditText) v.findViewById(R.id.ptnEdit);
....
et.addTextChangedListener(new TextWatcher() {
....
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dialog.city.header"
style="@style/Theme.AppCompat.Dialog"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WeatherActivity"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.mcxiaoke.volley:library:1.0.6@aar'
compile 'com.survivingwithandroid:weatherlib:1.5.3'
compile 'com.survivingwithandroid:weatherlib_volleyclient:1.5.3'
}
#include <spi.h>
#include <ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 130); // Arduino IP Add
EthernetServer server(80); // Web server
// Http data
String reqData; // Request from Smartphone
String header;