Skip to content

Instantly share code, notes, and snippets.

View yung-yu's full-sized avatar

Andy.li yung-yu

View GitHub Profile
import android.animation.Animator;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import java.util.Timer;
import java.util.TimerTask;
@yung-yu
yung-yu / gist:7ca188bb8b0d0f9b3222c8892a630996
Created May 15, 2017 03:46
讓Acitvity切換橫向直向不要重啟
AndroidManifest.xml
-----------------------------------
<activity
android:name=".DemoActivity"
android:screenOrientation="unspecified"
android:configChanges="orientation|screenSize"
/>
DemoActivity.java
-------------------------------
@yung-yu
yung-yu / gist:8e5afbc632112f52773f93ff2b8927ab
Created May 12, 2017 09:45
Android 截取手機畫面
MediaProjectionManager mediaProjectionManager =
(MediaProjectionManager) getApplication().getSystemService(
Context.MEDIA_PROJECTION_SERVICE);
startActivityForResult(
mediaProjectionManager.createScreenCaptureIntent(), CAPTURE_PERMISSION_REQUEST_CODE);
@yung-yu
yung-yu / gist:8485ab28e0bfe736cffddd19d61dbdb4
Created May 11, 2017 06:34
檢查 uri 從google相簿app回來,需要另外處理取得Uri
/**
* 檢查 uri 從google相簿app回來,需要另外處理取得Uri
* @param photoUri
* @return Uri
*/
public static Uri getExternalMediaUriFormContentUri(Uri photoUri){
if(photoUri.getAuthority() != null){
if(photoUri.getAuthority().equals("com.google.android.apps.photos.contentprovider")){
List<String> paths = photoUri.getPathSegments();
if(paths != null && paths.size() > 0){