'Android'에 해당되는 글 11건

  1. 2014.09.12 ScrollView 이동하기 (1)
  2. 2014.08.26 안드로이드 webview 텍스트 선택 막기
  3. 2014.08.18 안드로이드 네트워크 상태 확인
  4. 2014.08.12 이미지 flip 시키기
  5. 2014.08.12 Android WebView에 세션(쿠키) 공유하기
  6. 2014.08.12 모든 액티비티 종료 시키기
  7. 2014.08.01 WebView에서 카카오링크 또는 마켓 공유하기
2014.09.12 09:34

ScrollView 이동하기

맨 아래로 이동

 mScroll.fullScroll(View.FOCUS_DOWN); 


맨 위로 이동

 mScroll.fullScroll(View.FOCUS_UP); 

Trackback 0 Comment 1
2014.08.26 14:28

안드로이드 webview 텍스트 선택 막기

웹뷰에 들어가는 html의 css에 다음 element 추가

-webkit-user-select: none;


[출처] webview no selection/copy&paste

Trackback 0 Comment 0
2014.08.18 17:01

안드로이드 네트워크 상태 확인

boolean isNetworkConnectionAvailable() {
	ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
	NetworkInfo info = cm.getActiveNetworkInfo();
	if (info == null)
		return false;
	State network = info.getState();
	return (network == NetworkInfo.State.CONNECTED || network == NetworkInfo.State.CONNECTING);
}


[출처] How to check the network availability?

Trackback 0 Comment 0
2014.08.12 17:25

이미지 flip 시키기

1. 플립 메소드

public static final int FLIP_VERTICAL = 1;
public static final int FLIP_HORIZONTAL = 2;

private Bitmap flipImage(Bitmap src, int type) {
	// create new matrix for transformation
	Matrix matrix = new Matrix();
	// if vertical
	if (type == FLIP_VERTICAL) {
		// y = y * -1
		matrix.preScale(1.0f, -1.0f);
	}
	// if horizonal
	else if (type == FLIP_HORIZONTAL) {
		// x = x * -1
		matrix.preScale(-1.0f, 1.0f);
		// unknown type
	} else {
		return null;
	}

	// return transformed image
	return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(),
			matrix, true);
}


2. 이미지 플립 시키미(호출쪽)

ImageView imgView = (ImageView) findViewById(R.id.imageView);
imgView.setImageBitmap(flipImage(BitmapFactory.decodeResource(getResources(), R.drawable.img), FLIP_VERTICAL );


[출처] Image Flipping (Mirroring) in ImageView (Android)

Trackback 0 Comment 0
2014.08.12 17:03

Android WebView에 세션(쿠키) 공유하기

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_user_report);

	WebViwe webView = (WebView) findViewById(R.id.webview);

	CookieSyncManager.createInstance(this);
	cookieManager = CookieManager.getInstance();
	CookieSyncManager.getInstance().startSync();

	//도메인 url, 쿠키
	cookieManager.setCookie("user domain url", "cookie value");
}


[참조] Syncing cookies between an HttpClient and a WebView

Trackback 0 Comment 0
2014.08.12 16:57

모든 액티비티 종료 시키기

package com.hrupin;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public abstract class AppBaseActivity extends Activity {
	public static final String FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION = "com.hrupin.FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION";
	private BaseActivityReceiver baseActivityReceiver = new BaseActivityReceiver();
	public static final IntentFilter INTENT_FILTER = createIntentFilter();

	private static IntentFilter createIntentFilter() {
		IntentFilter filter = new IntentFilter();
		filter.addAction(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION);
		return filter;
	}

	protected void registerBaseActivityReceiver() {
		registerReceiver(baseActivityReceiver, INTENT_FILTER);
	}

	protected void unRegisterBaseActivityReceiver() {
		unregisterReceiver(baseActivityReceiver);
	}

	public class BaseActivityReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context context, Intent intent) {
			if (intent.getAction().equals(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION)) {
				finish();
			}
		}
	}

	protected void closeAllActivities() {
		sendBroadcast(new Intent(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION));
	}
}


적용해야 하는 액티비티 구현시 AppBaseActivity를 상속하고

액티비티들을 종료하고 싶은때 sendBroadCast(FINISH_ALL_ACTIVITIES_ACTIVITY_ACTION) 메소드 호출 


[출처] How to finish all activities in your Android application through simple call

Trackback 0 Comment 0
2014.08.01 10:23

WebView에서 카카오링크 또는 마켓 공유하기

웹뷰를 통해 카카오톡 공유나 마켓 링크 버튼을 누르면 아래의 오류가 나올경우 해결 방법

webView.setWebViewClient(new WebViewClient() {
	@Override
	public boolean shouldOverrideUrlLoading(WebView view, String url) {
		if (url.startsWith("kakaolink:") || url.startsWith("market:")) {
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri
					.parse(url));
			startActivity(intent);
		} else {
			view.loadUrl(url);
		}
		return true;
	}
});



[출처] 안드로이드 웹뷰를 통해 외부어플로 공유하기 (카카오톡 공유, 내보내기)

Trackback 0 Comment 0