Skip to content

Instantly share code, notes, and snippets.

View jschmid's full-sized avatar
📱

Jonas Schmid jschmid

📱
View GitHub Profile
@jschmid
jschmid / email.java
Created February 11, 2013 19:54
Android send an email Intent
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"you@gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
@jschmid
jschmid / version.java
Created February 11, 2013 18:27
Get android version code and version name
PackageManager manager = this.getPackageManager();
PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
Toast.makeText(this,
"PackageName = " + info.packageName + "\nVersionCode = "
+ info.versionCode + "\nVersionName = "
+ info.versionName + "\nPermissions = " + info.permissions, Toast.LENGTH_SHORT).show();
@jschmid
jschmid / Activity.java
Created February 5, 2013 10:53
Android Activity with a custom protocol
// In the onCreate()
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
Log.i(TAG, "Started by a user clicking " + urlStr);
doSomethingWithTheUrl(uri.toString(););
}
@jschmid
jschmid / AndroidManifest.xml
Last active December 12, 2015 04:18
Android keep screen on
<uses-permission android:name="android.permission.WAKE_LOCK" />
@jschmid
jschmid / SecureActivity.java
Created February 1, 2013 07:27
Secure Android Activity that does not allow clicks when in the background, and prevents screenshots.
package pro.schmid.android.secureapp;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
@jschmid
jschmid / AndroidManifest.xml
Created February 1, 2013 07:09
Poll the currently running Android Activity then replace it by our own
<uses-permission android:name="android.permission.GET_TASKS" />
@jschmid
jschmid / PostArrayHandler.cs
Last active September 26, 2015 20:18
Handling arrays in POST data with Nancy
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Nancy;
namespace NancyComponents
{
public class PostArrayHandler
{
public static object GetFormWithArrays(dynamic form)
{