Skip to content

Instantly share code, notes, and snippets.

View ludovicfrin's full-sized avatar

Ludovic FRIN ludovicfrin

View GitHub Profile
@ludovicfrin
ludovicfrin / ReadSmsActivity.java
Last active February 1, 2016 10:57
Lecture de la liste des SMS sous Android
/**
* Activité de lecture des SMS
*
* @author Ludovic FRIN
*/
public class ReadSmsActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks<Cursor> {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ludovicfrin
ludovicfrin / SendSmsActivity.java
Last active February 1, 2016 19:36
Envoi d'un SMS sous Android
public class SendSmsActivity extends AppCompatActivity {
...
private void sendSms(String recipient, String message) {
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(recipient, null, message, null, null);
} catch (Exceptione e) {
e.printStackTrace();
}
}
@ludovicfrin
ludovicfrin / web.xml
Last active February 1, 2016 19:45
web.xml Pour service RESTFul Jersey
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Jersey REST</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
@ludovicfrin
ludovicfrin / pom.xml
Last active February 1, 2016 19:59
pom.xml Pour service RESTFul Jersey
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.frin</groupId>
<artifactId>jersey</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jersey</name>
<description>Jersey REST</description>
<properties>
@ludovicfrin
ludovicfrin / Controller.java
Last active February 1, 2016 20:00
Contrôleur pour service RestFul Jersey
package fr.frin.jersey;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import fr.frin.phonesync.webapp.entity.Sms;
@ludovicfrin
ludovicfrin / pom.xml
Created February 2, 2016 09:19
Fichier pom.xml pour réalisation d'un service RESTFul avec le framework Spring
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.frin</groupId>
<artifactId>spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>spring</name>
<description>Spring REST</description>
<properties>
package fr.frin.spring;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Controleur
*
* @author Ludovic FRIN
*/
@ludovicfrin
ludovicfrin / web.xml
Last active February 2, 2016 09:33
Fichier web.xml pour projet RESTful avec le framework Spring
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Spring REST</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
@ludovicfrin
ludovicfrin / spring-servlet.xml
Last active February 2, 2016 09:33
Fichier spring-serlvet.xml pour réalisation d'un service RESTful avec le framework Spring
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="fr.frin.spring" />
float temperature;
int reading;
int pin = 5;
void setup()
{
analogReference(INTERNAL);
Serial.begin(9600);
}