This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String uniqueID = null; | |
private static final String PREF_UNIQUE_ID = "PREF_UNIQUE_ID"; | |
public synchronized static String id(Context context) { | |
if (uniqueID == null) { | |
SharedPreferences sp = context.getSharedPreferences(PREF_UNIQUE_ID, | |
Context.MODE_PRIVATE); | |
uniqueID = sp.getString(PREF_UNIQUE_ID, null); | |
if (uniqueID == null) { | |
uniqueID = UUID.randomUUID().toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ネットワーク接続チェック | |
* | |
* @param context | |
* @return | |
*/ | |
public static boolean isConnected() { | |
ConnectivityManager cm = (ConnectivityManager) MyApplication.getContext() | |
.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo ni = cm.getActiveNetworkInfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* validate your email address format. Ex-akhi@mani.com | |
*/ | |
public static boolean emailValidator(String email) { | |
Pattern pattern; | |
Matcher matcher; | |
final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; | |
pattern = Pattern.compile(EMAIL_PATTERN); | |
matcher = pattern.matcher(email); | |
return matcher.matches(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 緯度経度から2点間の距離をメートルで返す | |
* | |
* @param lat_a | |
* @param lng_a | |
* @param lat_b | |
* @param lng_b | |
* @return | |
*/ | |
public static double getDistance(double lat_a, double lng_a, double lat_b, double lng_b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxxxx.fragment; | |
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v4.app.DialogFragment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mGridView = (GridView) getView().findViewById(R.id.spotsView); | |
mGridView.setOnTouchListener(new GridView.OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
// ScrollViewの中でもうまくGridViewのScrollを効かす | |
int action = event.getAction(); | |
switch (action) { | |
case MotionEvent.ACTION_DOWN: | |
v.getParent().requestDisallowInterceptTouchEvent(true); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xx.xxx.xx.view; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.ViewGroup; | |
import android.widget.GridView; | |
/** | |
* ScrollViewの中のGridViewでも高さを可変にする<br> | |
* http://stackoverflow.com/questions/8481844/gridview-height-gets-cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sakura.example.myexamdialogfragment; | |
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
import android.support.v4.app.DialogFragment; | |
public class CommonDialogFragment extends DialogFragment { | |
private DialogListener listener = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.sakurafish.myexamplemaillink" | |
android:versionCode="1" | |
android:versionName="1.0" > | |
<uses-sdk | |
android:minSdkVersion="8" | |
android:targetSdkVersion="15" /> | |
<uses-permission android:name="android.permission.INTERNET" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.yochiand.myexampleandroidannotations" | |
android:versionCode="1" | |
android:versionName="1.0" > | |
<uses-sdk android:minSdkVersion="3" /> | |
<application | |
android:icon="@drawable/ic_launcher" |