Skip to content

Instantly share code, notes, and snippets.

@daichan4649
daichan4649 / AndroidManifest.xml
Last active December 21, 2015 12:19
物理メニューキーがある端末でも、ActionBar の overflowメニュー を強制的に表示する (for Android)
<application
android:name="daichan4649.actionbartest.TestApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="daichan4649.actionbartest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@daichan4649
daichan4649 / AndroidManifest.xml
Last active January 26, 2016 08:12
get GPS information (Android)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="daichan4649.gps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
@daichan4649
daichan4649 / AndroidManifest.xml
Last active December 19, 2015 23:59
custom actionbar (for Android) MenuFragment 動的切替
<activity
android:name=".XxxActivity"
android:theme="@style/Custom" />
@daichan4649
daichan4649 / Test.java
Last active December 19, 2015 23:49
画像ファイル内の EXIF 情報有無判定 (for Android)
public static boolean isExistLocationInfo(String filePath) {
if (TextUtils.isEmpty(filePath)) {
return false;
}
try {
ExifInterface exifIf = new ExifInterface(filePath);
float[] output = new float[2];
exifIf.getLatLong(output);
// GPS(0, 0) は取得失敗とみなす
if (output[0] == 0 && output[1] == 0) {
@daichan4649
daichan4649 / SelectModeDialogFragment.java
Last active December 19, 2015 19:39
DialogFragment 定番処理
public interface SelectModeDialogListener {
void onModeTypeSelected(ModeType selectedMode, int id);
}
public static DialogFragment newInstance(int id) {
Bundle args = new Bundle();
args.putInt("id", id);
DialogFragment fragment = new SelectModeDialogFragment();
fragment.setArguments(args);
return fragment;
@daichan4649
daichan4649 / layout.xml
Created June 29, 2013 07:02
GridLayout Sample (EditText/Spinner)
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3"
android:padding="8dip"
android:useDefaultMargins="true" >
@daichan4649
daichan4649 / AndroidManifest.xml
Last active December 19, 2015 03:28
録音/録画/音声検索
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.recordtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
@daichan4649
daichan4649 / RecordTest.java
Last active February 19, 2021 12:03
外部レコーダ(音声/動画)起動後に、保存データ(録音/録画)を取得 (Android)
private static final int REQ_CODE_MIC = 0;
private static final int REQ_CODE_MOVIE = 1;
private void startAudioRecorder() {
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
try {
startActivityForResult(intent, REQ_CODE_MIC);
} catch (Exception e) {
e.printStackTrace();
}
@daichan4649
daichan4649 / IMETest.java
Created April 30, 2013 09:49
エンター押下時にIME閉じる (for Android)
// EditText に listener を設定
// [EditText].setOnEditorActionListener(mEditorActionListener);
private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
hideIME(v);
}
return false;
@daichan4649
daichan4649 / OptionMenuSample.java
Created April 30, 2013 09:40
show option menu (for Android)
// Fragment
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_search, menu);