This file contains hidden or 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"?> | |
<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" |
This file contains hidden or 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
public class SignalStrengthListener extends PhoneStateListener { | |
@Override | |
public void onSignalStrengthsChanged(SignalStrength signalStrength) { | |
super.onSignalStrengthsChanged(signalStrength); | |
boolean isGsm = signalStrength.isGsm(); | |
// Get the CDMA RSSI value in dBm | |
int iCdmaDbm = signalStrength.getCdmaDbm(); | |
// Get the CDMA Ec/Io value in dB*10 |
This file contains hidden or 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
ColorMatrixColorFilter setContrast(float contrast) { | |
float scale = contrast + 1.f; | |
float translate = (-.5f * scale + .5f) * 255.f; | |
float[] array = new float[] { | |
scale, 0, 0, 0, translate, | |
0, scale, 0, 0, translate, | |
0, 0, scale, 0, translate, | |
0, 0, 0, 1, 0}; | |
ColorMatrix matrix = new ColorMatrix(array); | |
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix); |
This file contains hidden or 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
// from http://d.hatena.ne.jp/Superdry/20110130/1296405341 | |
private int[] convertRGB2YUV(int color) { | |
ColorMatrix cm = new ColorMatrix(); | |
cm.setRGB2YUV(); | |
final float[] yuvArray = cm.getArray(); | |
int r = Color.red(color); | |
int g = Color.green(color); | |
int b = Color.blue(color); | |
int[] result = new int[3]; |
This file contains hidden or 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
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 |
This file contains hidden or 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 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); |
This file contains hidden or 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
// 配列要素をカンマ区切の文字列に変換してくれる | |
Arrays.toString(配列要素) | |
// 指定された配列の「深層内容」の文字列表現を返す。 | |
Arrays.deepToString(Object[] a) | |
// 配列をListに変換 | |
List<String> list = Arrays.asList(strs); | |
//ListからStringの配列に変換 |
This file contains hidden or 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
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; |
This file contains hidden or 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
// copy from http://goo.gl/NxT8B | |
private LocationManager mLocationManager; | |
private String mBestProvider; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// 位置情報サービスマネージャを取得 |
This file contains hidden or 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
final WifiManager mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); | |
if(mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) { | |
// register WiFi scan results receiver | |
IntentFilter filter = new IntentFilter(); | |
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); | |
registerReceiver(new BroadcastReceiver(){ | |
@Override |
OlderNewer