public static String getVersion(Context context) {
    String version = null;
    
    try {
      PackageInfo i = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
      version = i.versionName;
    } catch (PackageManager.NameNotFoundException e) {
      
    }
    
    return version;
  }

'android' 카테고리의 다른 글

SharedPreferences  (0) 2019.04.08
앱 이름 가져오기  (0) 2019.04.08
JSON String 파싱하기  (0) 2019.03.20
안드로이드 UI 라이브러리 모음  (0) 2019.03.05
setDisplayShowCustomEnabled 뒤로 가기 색상 변경  (0) 2018.10.30
public static ArrayList<HashMap<String, String>> parseJSON(Context context, String jsonString ) {
ArrayList<HashMap<String, String>> rtn = new ArrayList<HashMap<String, String>>();

try {
JSONArray array = new JSONArray("[" + jsonString + "]");

for( int i = 0; i < array.length(); i++ ) {
HashMap<String, String> map = new HashMap<String, String>();

JSONObject object = array.getJSONObject(i);
Iterator<?> keys = object.keys();

while(keys.hasNext()) {
String key = (String) keys.next();
String val = object.getString(key);

map.put(key, val);
}

rtn.add(i, map);

map = null;
}
} catch (JSONException e) {
e.printStackTrace();
}

return rtn;
}

JSonString 포맷이 대괄호가 없을 경우 붙여주고 대괄호가 있을 경우 지우고 사용하세요


'android' 카테고리의 다른 글

앱 이름 가져오기  (0) 2019.04.08
버전 정보 가져오기  (0) 2019.04.08
안드로이드 UI 라이브러리 모음  (0) 2019.03.05
setDisplayShowCustomEnabled 뒤로 가기 색상 변경  (0) 2018.10.30
VectorDrawable를 Bitmap로 변환  (0) 2018.03.07

https://github.com/wasabeef/awesome-android-ui

'android' 카테고리의 다른 글

버전 정보 가져오기  (0) 2019.04.08
JSON String 파싱하기  (0) 2019.03.20
setDisplayShowCustomEnabled 뒤로 가기 색상 변경  (0) 2018.10.30
VectorDrawable를 Bitmap로 변환  (0) 2018.03.07
pendingIntent Flag 옵션  (1) 2018.02.02
<item name="android:textColorSecondary">@color/white</item>


'android' 카테고리의 다른 글

JSON String 파싱하기  (0) 2019.03.20
안드로이드 UI 라이브러리 모음  (0) 2019.03.05
VectorDrawable를 Bitmap로 변환  (0) 2018.03.07
pendingIntent Flag 옵션  (1) 2018.02.02
TextView 선택 복사  (0) 2018.01.19


public static Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
Drawable drawable = ContextCompat.getDrawable(context, drawableId);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate();
}

Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);

return bitmap;
}


'android' 카테고리의 다른 글

안드로이드 UI 라이브러리 모음  (0) 2019.03.05
setDisplayShowCustomEnabled 뒤로 가기 색상 변경  (0) 2018.10.30
pendingIntent Flag 옵션  (1) 2018.02.02
TextView 선택 복사  (0) 2018.01.19
비트맵 파일로 떨어트리기  (0) 2017.12.14

FLAG_CANCEL_CURRENT : 이전에 생성한 PendingIntent 는 취소하고 새롭게 만든다.

FLAG_NO_CREATE : 생성된 PendingIntent 를 반환한다. 재사용 가능하다.

FLAG_ONE_SHOT : 이 flag 로 생성한 PendingIntent 는 일회용이다.

FLAG_UPDATE_CURRENT : 이미 생성된 PendingIntent 가 존재하면 해당 Intent 의 내용을 변경한다.


출처: http://mission12.tistory.com/89 [제자와 나눔]

<TextView
android:id="@+id/tvContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true" />

빨간색 부분 옵션을 추가하면됨

'android' 카테고리의 다른 글

VectorDrawable를 Bitmap로 변환  (0) 2018.03.07
pendingIntent Flag 옵션  (1) 2018.02.02
비트맵 파일로 떨어트리기  (0) 2017.12.14
웹뷰 바로 전의 URL 가져오기  (0) 2017.12.12
코드로 원 그리기  (0) 2017.12.11

String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/Download");
myDir.mkdirs();

String fname = "image.jpg";

File file = new File (myDir, fname);
if (file.exists ()) file.delete ();
try {
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();

Toast.makeText(mContext, fname + "다운로드 되었습니다", Toast.LENGTH_SHORT).show();

} catch (Exception e) {
e.printStackTrace();
}


'android' 카테고리의 다른 글

pendingIntent Flag 옵션  (1) 2018.02.02
TextView 선택 복사  (0) 2018.01.19
웹뷰 바로 전의 URL 가져오기  (0) 2017.12.12
코드로 원 그리기  (0) 2017.12.11
마테리얼 디자인 정리가 잘되어있어 올립니다.  (0) 2017.12.02
WebBackForwardList webBackForwardList = mWebView.copyBackForwardList();
String backUrl = webBackForwardList.getItemAtIndex(webBackForwardList.getCurrentIndex() - 1).getUrl();


'android' 카테고리의 다른 글

TextView 선택 복사  (0) 2018.01.19
비트맵 파일로 떨어트리기  (0) 2017.12.14
코드로 원 그리기  (0) 2017.12.11
마테리얼 디자인 정리가 잘되어있어 올립니다.  (0) 2017.12.02
LTE, WIFI, Network 체크  (0) 2017.12.02

ShapeDrawable oval = new ShapeDrawable (new OvalShape());
oval.getPaint().setStyle(Paint.Style.STROKE); // 테두리 선 스타일
oval.getPaint().setStrokeWidth(2); //테두리 선 굵기
oval.getPaint().setAntiAlias(true);
oval.getPaint().setColor(getResources().getColor(R.color.lightGray)); // 색상지정


+ Recent posts