Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / pom.xml
Created May 1, 2014
[Android][Maven][AndroidAnnotations] androidManifestFile options in pom.xml
View 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 Nov 5, 2014
Android Studio build.gradle Template of dependencies
View build.gradle
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 Mar 7, 2011 — forked from aharisu/gist:857961
[Android][Layout] Tab on the bottom with TabView
View gist:858063
<?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 Mar 31, 2011
[Android]Getting the path of each directory
View gist:895848
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 Mar 31, 2011
[Android]Cropped image
View gist:895862
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
[Android]Handler
View gist:982578
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 Jun 14, 2011
[android][GPS]LocationManager
View gist:1024384
// 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 Jun 15, 2011
[Android][Bluetooth]Bluetooth Discovery
View gist:1026660
// 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 Jun 23, 2011
[Android]Repeatedly running the Service in the Alarm Manager
View To start the repeatedly running.java
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);