'Programming > Java' 카테고리의 다른 글
| java 람다, 클로저 (0) | 2025.01.31 |
|---|---|
| java oop 개념 (0) | 2020.01.15 |
| java cipher (0) | 2019.11.25 |
| jaxb - Java Architecture for XML Binding (0) | 2019.06.25 |
| jar 실행하기 (0) | 2019.01.15 |
| java 람다, 클로저 (0) | 2025.01.31 |
|---|---|
| java oop 개념 (0) | 2020.01.15 |
| java cipher (0) | 2019.11.25 |
| jaxb - Java Architecture for XML Binding (0) | 2019.06.25 |
| jar 실행하기 (0) | 2019.01.15 |
string.xml 에는 아래와 같이 되어있는데
안드로이드 스튜디오에서는 string editor 쓰면 된다지만, 솔찍히 너무 느려서(i5-2500을 탓해야 하나..)
string.xml에 복붙해서 수정하는데 훨신 빠르다.
| <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello!</string> </resources> |
액티비티 xml 쪽에서는 아래와 같이 @string/문자열식별자 식으로 쓴다.
| <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> |
도움말 안보고 막 쓰다 보니 되서 냅두긴 했는데.. 이게 코드에서는 정석인가?
| String string = getString(R.string.hello); |
[링크 : https://appcafe.tistory.com/31]
[링크 : https://developer.android.com/guide/topics/resources/string-resource?hl=ko]
+
i18n 적용은, values-국가코드 식으로 구분해서 쓰면 되는 듯
| res/values/strings.xml res/values-fr/strings.xml res/values-ja/strings.xml |
이미지도 문자열 처럼 drawable-국가코드 식으로 되는 듯
| res/drawable/ res/drawable-ja/ |
[링크 : https://developer.android.com/guide/topics/resources/localization?hl=ko]
| 안드로이드 64bit 지원 (0) | 2021.07.27 |
|---|---|
| 핸드폰으로 만든 앱 올리기 (0) | 2020.06.17 |
| 안드로이드 HTTP를 이용한 REST API 호출 (0) | 2020.06.10 |
| retrofit 어렵네.. (0) | 2020.06.09 |
| Android Logcat (0) | 2020.06.09 |
말은 거창한데 Retrofit2 사용하려다가 (못해먹겠어서)
간단하게 부르기만 하고
JSON 결과받아오지 않기 때문에 파싱을 하지 않아도 되기 때문에
wget이나 curl 처럼 단순하게 호출만 하는 녀석을 찾아 봄
AsyncTask 라는걸 쓰니 간단하게 구현이 가능하다.
import android.os.AsyncTask;
import android.util.Log;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class RestAPITask extends AsyncTask {
// Variable to store url
protected String mURL;
// Constructor
public RestAPITask(String url) {
mURL = url;
}
// Background work
@Override
protected Object doInBackground(Object[] objects) {
String result = null;
try {
// Open the connection
URL url = new URL(mURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
InputStream is = conn.getInputStream();
// Get the stream
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF_8"));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
// Set the result
result = builder.toString();
}
catch (Exception e) {
// Error calling the rest api
Log.e("REST_API", "GET method failed: " + e.getMessage());
e.printStackTrace();
}
return null;
}
}
아래는 호출하는 쪽. 경고가 발생하는데 일단 무시중
new RestAPITask("http://192.168.219.201:3000/api/ws").execute();
| 핸드폰으로 만든 앱 올리기 (0) | 2020.06.17 |
|---|---|
| 안드로이드 문자열 (string.xml) (0) | 2020.06.11 |
| retrofit 어렵네.. (0) | 2020.06.09 |
| Android Logcat (0) | 2020.06.09 |
| 안드로이드 could not find method (0) | 2020.06.07 |
패키지 하나 쓰기 왜케 어럽냐..
okhttp를 따로 끌어와야 하나? 자동으로 끌려온다는 말이 있어서 안끌어왔더니 에러난다.
근데 구버전인지.. 지금 버전에 하면 compile 대신 implementation을 쓰라고 경고를 띄운다.
그리고 최신버전은 2.6.1 인데 2.3.0 으로 떨어지다니..
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
[링크 : https://www.journaldev.com/13639/retrofit-android-example-tutorial]
+
Call() 에 결과 없이(JSON으로 받지 않고) 처리하는 방법
@GET("path/to/void/api")
Call<Void> garageMove();
[링크 : https://stackoverflow.com/questions/47237106/retrofit-2-3-url-call-without-return-value]
+
2020.06.16
어노테이션 설명이 있어서 좀 보기가 수월한 듯.
| 안드로이드 문자열 (string.xml) (0) | 2020.06.11 |
|---|---|
| 안드로이드 HTTP를 이용한 REST API 호출 (0) | 2020.06.10 |
| Android Logcat (0) | 2020.06.09 |
| 안드로이드 could not find method (0) | 2020.06.07 |
| android studio - constraint layout 어렵네 (0) | 2020.06.07 |
기본으로 될 줄 알았는데, 자바를 너무 만능으로 생각한걸까..
아무튼 logcat 이라는 기능이 android.util.Log 패키지로 존재하기 때문에 사용하려면 import 해주어야 한다.
| import android.util.Log; |
사용 방법은 다음과 같이
Error / Warning / Information / Debug / Verbose 의 약자로 붙이면 된다.
| Log.e(String, String) (오류) Log.w(String, String) (경고) Log.i(String, String) (정보) Log.d(String, String) (디버그) Log.v(String, String) (상세) |
[링크 : https://developer.android.com/studio/debug/am-logcat?hl=ko]
| 안드로이드 HTTP를 이용한 REST API 호출 (0) | 2020.06.10 |
|---|---|
| retrofit 어렵네.. (0) | 2020.06.09 |
| 안드로이드 could not find method (0) | 2020.06.07 |
| android studio - constraint layout 어렵네 (0) | 2020.06.07 |
| 안드로이드 앱 방향 설정하기 (0) | 2020.06.07 |
UI에 onClick 함수 하나가 이름이 잘못되었을 뿐인데(!)
어떠한 버튼을 누르던 에러가 발생을 했다.
일단 에러 자체는 해당 함수를 찾을수 없다는 것인데
런타임에서 너무 광범위 하게 에러를 발생 시키는듯?
| retrofit 어렵네.. (0) | 2020.06.09 |
|---|---|
| Android Logcat (0) | 2020.06.09 |
| android studio - constraint layout 어렵네 (0) | 2020.06.07 |
| 안드로이드 앱 방향 설정하기 (0) | 2020.06.07 |
| 안드로이드 AVD 구동되지 않을 경우 (TSC frequency mismatch) (0) | 2020.06.07 |
키즈카페에 와서 느긋하게 에러를 읽으면서 하는데 음.. 그러니까 0,0 으로 뛰니 제한을 걸어주면 되는건가 싶어서

메뉴를 찾아보니 해당 기능을 발견! 하나하나 지정해주니 에러는 사라진다.

constraint를 버튼 하나마다 위에서, 왼쪽에서 이런식으로 다 지정을 해주었더니

너.. 어디로 가니 -ㅁ-?

+
| Android Logcat (0) | 2020.06.09 |
|---|---|
| 안드로이드 could not find method (0) | 2020.06.07 |
| 안드로이드 앱 방향 설정하기 (0) | 2020.06.07 |
| 안드로이드 AVD 구동되지 않을 경우 (TSC frequency mismatch) (0) | 2020.06.07 |
| android studio - git push rejected (0) | 2020.06.07 |
되긴 한데.. 경고가 뜨네?
이거 말고 이전에 MainActivity.java 에서 강제로 방향 설정할때도 경고 뜨던데.. 그냥 무시해도 되려나?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rpiremotecontrol">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
[링크 : https://alvinalexander.com/.../how-do-i-make-my-android-app-display-landscape-mode-only/]
| 안드로이드 could not find method (0) | 2020.06.07 |
|---|---|
| android studio - constraint layout 어렵네 (0) | 2020.06.07 |
| 안드로이드 AVD 구동되지 않을 경우 (TSC frequency mismatch) (0) | 2020.06.07 |
| android studio - git push rejected (0) | 2020.06.07 |
| 안드로이드 retrofit2 사용하기 (0) | 2020.06.03 |
오전 10:47 Emulator: qemu-system-i386: warning: TSC frequency mismatch between VM (2494335 kHz) and host (2494333 kHz), and TSC scaling unavailable
위와 같은 에러가 발생해서 확인해보니
AVD Manager에서 Wipe Data 하면 된다고 한다.
일단 저장 공간이 4기가 먹던게 2.4로 줄어들고 처음부터 구동하더니 잘 된다.

[링크 : https://askubuntu.com/questions/1005268/qemu-frequency-mismatch-on-kubuntu]
| android studio - constraint layout 어렵네 (0) | 2020.06.07 |
|---|---|
| 안드로이드 앱 방향 설정하기 (0) | 2020.06.07 |
| android studio - git push rejected (0) | 2020.06.07 |
| 안드로이드 retrofit2 사용하기 (0) | 2020.06.03 |
| 안드로이드 조이스틱 UI 만들기 (0) | 2020.05.29 |
요즘 개발을 안했더니 바보가 된 느낌?
일단 github에 저장소 생성하고
git remote에 등록을 한다고 해서 저장소가 끌려오는게 아닌데 착각을 해서 헤매는 중
안드로이드 스튜디오 git 사용하려면
github에서
1. git repository 생성
안드로이드 스튜디오에서
2. git remote 등록
3. git pull
4. git branch 실행 remote 의 origin/master 으로 rebase
5. git push
[링크 : https://comoi.io/235]
| 안드로이드 앱 방향 설정하기 (0) | 2020.06.07 |
|---|---|
| 안드로이드 AVD 구동되지 않을 경우 (TSC frequency mismatch) (0) | 2020.06.07 |
| 안드로이드 retrofit2 사용하기 (0) | 2020.06.03 |
| 안드로이드 조이스틱 UI 만들기 (0) | 2020.05.29 |
| 안드로이드 retrofit 사용하기 (0) | 2020.05.29 |