Skip to content

Instantly share code, notes, and snippets.

View ssaurel's full-sized avatar

Sylvain Saurel ssaurel

View GitHub Profile
@ssaurel
ssaurel / AndroidManifest.xml
Created December 5, 2016 11:32
Android Manifest for the App with Splash Screen
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ssaurel.splashscreen">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@ssaurel
ssaurel / main_activity.xml
Created January 11, 2017 08:43
Main activity layout for a JSoup Tutorial
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
@ssaurel
ssaurel / MainActivity.java
Created January 11, 2017 08:44
Code to parse HTML Page with JSoup on Android
package com.ssaurel.jsouptut;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@ssaurel
ssaurel / activity_main.xml
Created January 30, 2017 14:19
Flip Coin App Main Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
@ssaurel
ssaurel / MainActivity.java
Created January 30, 2017 14:20
Flip Coin App Main Activity Java Code
package com.ssaurel.coinflip;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
@ssaurel
ssaurel / JSSEProvider.java
Created March 9, 2017 20:43
JSSEProvider implementation from Alexander Y. Kleymenov
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ssaurel
ssaurel / ByteArrayDataSource.java
Created March 9, 2017 20:45
ByteArrayDataSource for the Java Mail API on Android Tutorial
public class ByteArrayDataSource implements DataSource {
private byte[] data;
private String type;
public ByteArrayDataSource(byte[] data, String type) {
super();
this.data = data;
this.type = type;
}
@ssaurel
ssaurel / GMailSender.java
Created March 9, 2017 20:48
GMailSender class for the Java Mail API on Android tutorial
public class GMailSender extends javax.mail.Authenticator {
private String mailhost = "smtp.gmail.com";
private String user;
private String password;
private Session session;
static {
Security.addProvider(new JSSEProvider());
}
@ssaurel
ssaurel / Thread.java
Last active March 9, 2017 20:50
Block of code to call the GMailSender class
new Thread(new Runnable() {
@Override
public void run() {
try {
GMailSender sender = new GMailSender("sylvain.saurel@gmail.com",
"your_password");
sender.sendMail("Hello from JavaMail", "Body from JavaMail",
"sylvain.saurel@gmail.com", "sylvain.saurel@gmail.com");
} catch (Exception e) {
@ssaurel
ssaurel / activity_main.xml
Created March 20, 2017 13:38
Layout for the phone call tutorial on Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"