Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / pom.xml
Created May 1, 2014 08:59
[Android][Maven][AndroidAnnotations] androidManifestFile options in pom.xml
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<!-- does not work. -->
<!--
<compilerArguments>
<AandroidManifestFile>${project.basedir}/src/main/AndroidManifest.xml</AandroidManifestFile>
@granoeste
granoeste / build.gradle
Created November 5, 2014 01:07
Android Studio build.gradle Template of dependencies
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'android-power-assert'
group = 'net.granoeste'
version = '1.0.0'
def AAVersion = '3.0.1'
android {
@granoeste
granoeste / gist:858063
Created March 7, 2011 04:18 — forked from aharisu/gist:857961
[Android][Layout] Tab on the bottom with TabView
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
@granoeste
granoeste / gist:895848
Created March 31, 2011 05:05
[Android]Getting the path of each directory
File dir = context.getFilesDir(); // /data/data/package/files
File dir = context.getCacheDir(); // /data/data/package/cache
File dir = Environment.getDataDirectory(); // /data
File dir = Environment.getDownloadCacheDirectory(); // /cache
File dir = Environment.getExternalStorageDirectory(); // /sdcard
File dir = Environment.getRootDirectory(); // /system
@granoeste
granoeste / gist:895862
Created March 31, 2011 05:24
[Android]Cropped image
private final int REQUEST_CROP_GALLERY=1;
private File mTempFile;
public void onClick(View v) {
try {
mTempFile = getTempFile();
// Launch picker to choose photo for selected contact
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
@granoeste
granoeste / gist:982578
Created May 20, 2011 08:45
[Android]Handler
final private Handler mHandler = new Handler() {
@Override
public void handleMessage(final Message msg) {
switch (msg.what) {
case MESSAGE_ONE:
// TODO:
return;
case MESSAGE_TWO:
// TODO:
return;
@granoeste
granoeste / gist:1024384
Created June 14, 2011 05:36
[android][GPS]LocationManager
// copy from http://goo.gl/NxT8B
private LocationManager mLocationManager;
private String mBestProvider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 位置情報サービスマネージャを取得
@granoeste
granoeste / gist:1026660
Created June 15, 2011 07:48
[Android][Bluetooth]Bluetooth Discovery
// Create a BroadcastReceiver for ACTION_FOUND and ACTION_DISCOVERY_FINISHED
private final BroadcastReceiver mDeviceDiscoverReceiver = new BroadcastReceiver() {
int cnt = 0;
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@granoeste
granoeste / To start the repeatedly running.java
Created June 23, 2011 07:08
[Android]Repeatedly running the Service in the Alarm Manager
Intent serviceIntent = new Intent(this, MyService.class);
PendingIntent pendingIntent
= PendingIntent.getService(this, 0, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.setInexactRepeating (
AlarmManager.RTC,
System.currentTimeMillis(),
//AlarmManager.INTERVAL_HOUR,
AlarmManager.INTERVAL_FIFTEEN_MINUTES,
pendingIntent);