Skip to content

Instantly share code, notes, and snippets.

@waveacme
waveacme / Makefile
Created March 17, 2016 08:14
general Makefile
CC=gcc
CFLAGS=-Wall -IDIR
LDFLAGS=-LDIR -lfoo
TARGET= a.out
#SOURCES=bar.c
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
@waveacme
waveacme / json_post_example.c
Last active March 11, 2016 03:53
use libcurl and json-c to build and send http post package in c
#include <stdio.h>
#include <string.h>
#include <json/json.h>
#include <curl/curl.h>
/*
* to install lib:
* apt-cache search ^libcurl
* apt-get install <whatever_apt-cache_listed>
@waveacme
waveacme / DecodeActivity.java
Created January 15, 2016 08:30
MediaCodec decode h264 example
//from https://github.com/vecio/MediaCodecDemo
package io.vec.demo.mediacodec;
import java.nio.ByteBuffer;
import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
@waveacme
waveacme / MyHandlerThread.java
Created January 15, 2016 03:04
fix Cannot resolve sambol 'THREAD_PRIORITY_BACKGROUND' in HandlerThread
//fix
import android.os.Process;
HandlerThread thread = new HandlerThread("work thread", Process.THREAD_PRIORITY_BACKGROUND);
@waveacme
waveacme / MainActivity.java
Created January 15, 2016 02:49
how to check service running stat in android
public class MainActivity extends Activity {
//...
public void CheckService(View v) {
boolean isRunning = isMyServiceRunning(myService.class);
Log.d(TAG, "my service running status: " + isRunning);
}
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
@waveacme
waveacme / LocalBroadcastExampleActivity.java
Last active January 15, 2016 02:18 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;