Skip to content

Instantly share code, notes, and snippets.

View sakurabird's full-sized avatar
💭
I may be slow to respond.

Yukari Sakurai sakurabird

💭
I may be slow to respond.
View GitHub Profile
@sakurabird
sakurabird / gist:6869046
Created October 7, 2013 14:36
emailの入力チェック
/**
* 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();
@sakurabird
sakurabird / gist:6869087
Created October 7, 2013 14:38
Androidのネットワーク接続チェック
/**
* ネットワーク接続チェック
*
* @param context
* @return
*/
public static boolean isConnected() {
ConnectivityManager cm = (ConnectivityManager) MyApplication.getContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
@sakurabird
sakurabird / gist:6922497
Last active December 25, 2015 05:09
(android)UUIDの取得
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();
@sakurabird
sakurabird / gist:6922598
Last active December 25, 2015 05:09
(android)TextViewの文字をスクロールする。プログラムから。
TextView tv = (TextView) findViewById(R.id.text);
tv.setSingleLine(); // 文字列を1行で表示. これがないと複数行に渡って表示されてしまうので、スクロールできない
tv.setFocusableInTouchMode(true);
tv.setEllipsize(TruncateAt.MARQUEE);
tv.setText("124567890-^9p@焦ったスクロールskxってちょうど私もでらっしゃるのかしら");
@sakurabird
sakurabird / AnimationTest1.java
Last active May 18, 2021 03:00
(android)TextViewの文字をスクロールする。xmlでアニメーションを定義する。 右から文字が流れてきて一番左までマーキーしたら止まる。
package com.example.AnimationTest1;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
public class AnimationTest1 extends Activity
{
@Override
@sakurabird
sakurabird / MainActivity.java
Last active December 25, 2015 05:09
(android)TextViewの文字をスクロールする。 Create an auto-Scrolling Marquee TextView in android http://androidsnips.blogspot.jp/2011/12/create-auto-scrolling-marquee-textview.html より focusしてなくてもスクロールできる。
package sakura.example.myexamplemojiscroll4;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@sakurabird
sakurabird / gist:6923039
Last active December 25, 2015 05:18
(android)KAKAOにIntentを送る
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "かかおにおくりたいSubject");
intent.putExtra(Intent.EXTRA_TEXT, "カカオに送りたいText");
intent.setPackage("com.kakao.talk");
try {
startActivity(intent);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "KAKAOがインストールされていません", Toast.LENGTH_LONG)
.show();
@sakurabird
sakurabird / gist:6923067
Last active August 4, 2017 14:16
(android) LINEにIntentを送る
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("line://msg/text/" + "LINEに送りたいテキストの内容"));// ブラウザ起動
try {
startActivity(intent);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "LINEアプリがインストールされていません", Toast.LENGTH_LONG)
.show();
}
@sakurabird
sakurabird / gist:6923154
Created October 10, 2013 18:29
android ギャラリーを呼び出し、選択したイメージのファイルパスを取得する
public void onClick5(View view) {
// ギャラリー呼び出し
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, REQUEST_GALLERY);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@sakurabird
sakurabird / gist:6923208
Created October 10, 2013 18:33
(android)TwitterにIntentを送る
String textString = "てすと";
String url = "https://twitter.com/intent/tweet?source=webclient&text=" + textString;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
try {
startActivity(intent);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Twitterアプリがインストールされていません", Toast.LENGTH_LONG)
.show();