This example show a list of taken time of image files. You can see images of certain month by selecting an item of spinner.
download
2013년 12월 22일 일요일
2013년 10월 10일 목요일
java.lang.IllegalStateException: ActionBarImpl can only be used with a compatible window decor layout
add this to the style:
parent="@android:style/Theme.Dialog"
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
parent="@android:style/Theme.Dialog"
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
2013년 8월 28일 수요일
how to remove title from actionbar
This is how to remove title from action bar using appcompat.
First, add the following lines to styles.xml in res/values folder.
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions">showHome|useLogo</item>
<item name="displayOptions">showHome|useLogo</item>
</style>
</resources>
Then, change android:theme attribute of your activity in manifest file.
<activity
android:name="MainActivity2"
android:theme="@style/AppTheme" >
You should use same name like the blue text above.
First, add the following lines to styles.xml in res/values folder.
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:displayOptions">showHome|useLogo</item>
<item name="displayOptions">showHome|useLogo</item>
</style>
</resources>
Then, change android:theme attribute of your activity in manifest file.
<activity
android:name="MainActivity2"
android:theme="@style/AppTheme" >
You should use same name like the blue text above.
2013년 8월 21일 수요일
invalid utf-8 start byte
change charset and(or) pageEncoding to UTF-8.
<%@ page language="java" contentType="application/json; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page language="java" contentType="application/json; charset=UTF-8"
pageEncoding="UTF-8"%>
2013년 8월 19일 월요일
Could not extract response: no suitable HttpMessageConverter found
Check if content type of server side(for example, jsp file) is
pageEncoding="EUC-KR"%>
application/json(if it is json).
<%@ page language="java" contentType="application/json; charset=EUC-KR"
pageEncoding="EUC-KR"%>
2013년 8월 14일 수요일
2013년 8월 7일 수요일
how to get 100% correct key hash for facebook auth
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
Put the above code in any class file of your app to get correct key hash.
Change "com.facebook.samples.hellofacebook" to your package name. Check log to get key hash and put the hash in the setting of facebook app. 2013년 8월 5일 월요일
Session: an attempt was made to request new permissions for a session that has a pending request
It can be key hash problem. make key hash with release key, and add the key at facebook apps setting with debug key hash. I guess debug key hash is not working.
2013년 7월 25일 목요일
animation not working in Fragments
use android.support.v4.app.Fragment instead of android.apps.Fragment.
2013년 7월 8일 월요일
2013년 7월 3일 수요일
Can not deserialize instance of java.util.ArrayList out of START_OBJECT
I found out the variable is not ArrayList. It doesn't have "[". Yes, it is json.
2013년 7월 2일 화요일
how to solve encoding problem of restTemplate
I encoded parameter of a url in UTF-8, and ran restTemplate. But I got error. I checked spelling of url again, but nothing was wrong. I found out restTemplate encoded url into Unicode.
The following is not working.
final String url = ApiUrls.areaBasedListApi + parameter;
// Initiate the request and return the results.
return restTemplate.getForObject(url, AreaBasedListData.class);
The following is working.
final String url = ApiUrls.areaBasedListApi + parameter;
// Initiate the request and return the results.
URI uri = new URI(url);
return restTemplate.getForObject(uri, AreaBasedListData.class);
The following is not working.
final String url = ApiUrls.areaBasedListApi + parameter;
// Initiate the request and return the results.
return restTemplate.getForObject(url, AreaBasedListData.class);
The following is working.
final String url = ApiUrls.areaBasedListApi + parameter;
// Initiate the request and return the results.
URI uri = new URI(url);
return restTemplate.getForObject(uri, AreaBasedListData.class);
2013년 6월 25일 화요일
How to use ndk-build in eclipse
Choose Builders on the left pane of Properties of Android NDK project.
Click New button to make new builder, and choose program.
Type the name of builder(for example, Native Builder), and enter the path of bash.exe of cygwin under Location. Set path of bin folder of Cygwin as Working Directory. Put in the following command in the Arguments box.
--login -c "cd /cygdrive/c/Users/user/development/adt-bundle-windows-x86_64/android-ndk-r8e && ./ndk-build -C /cygdrive/c/Users/user/workspace2/HelloNDK"
"/cygdrive/c/Users/user/development/adt-bundle-windows-x86_64/android-ndk-r8e" is my path of android ndk. You should change it to your path. Be aware that cygwin use different path writing against dos's. "/cygdrive/c/Users/user/workspace2/HelloNDK" is my path to android ndk project. You should change it to your path also.
Click New button to make new builder, and choose program.
Type the name of builder(for example, Native Builder), and enter the path of bash.exe of cygwin under Location. Set path of bin folder of Cygwin as Working Directory. Put in the following command in the Arguments box.
--login -c "cd /cygdrive/c/Users/user/development/adt-bundle-windows-x86_64/android-ndk-r8e && ./ndk-build -C /cygdrive/c/Users/user/workspace2/HelloNDK"
"/cygdrive/c/Users/user/development/adt-bundle-windows-x86_64/android-ndk-r8e" is my path of android ndk. You should change it to your path. Be aware that cygwin use different path writing against dos's. "/cygdrive/c/Users/user/workspace2/HelloNDK" is my path to android ndk project. You should change it to your path also.
Now move to Refresh tab. Check Refresh resources upon completion. Click Specific resources and then click Specify resources button. check libs folder of android ndk project.
Move to Build Options tab. Choose Allocate console, During auto builds. If you don't want to see ndk log, click Launch in background. Check specify working set of relevant resources. Click Specify resources button and select jni folder and all the files in it.
Click ok, and you will see new builder. Now ndk will be built automatically when you clean or build the ndk project(libs and obj folder will be created). Very nice!!
2013년 6월 23일 일요일
NetworkOnMainThreadException
I got the NetworkOnMainThreadException. So I used Aynctask to avoid the error, but I got the same error. I googled about this, and I found out that if strict mode turned on, the error shows up even though I use Asynctask. I used LruCache, and the cache got the strict mode turn on. I turned off the strict mode, now the error disappeared. The following is how to turn off the strict mode.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
2013년 6월 17일 월요일
can not launch debug mode
It has worked fine. But today I can not launch debug mode. I don't know why. I found a solution at stackoverflow.
Try right-clicking (or control-clicking) on the project name and select
Debug As Android Application
Debug As Android Application
2013년 6월 13일 목요일
SNS Manager Plus English Manual
Are you bored with managing accounts of Twitter, Facebook and Google Plus? Now manage your SNS with SNS Manager Plus in ease. You can post at all of your sns with one click.
There are two types of post. One is just sending text message and the other is sending text message and image all together. SNS Manager Plus doesn't not support video.
If you want to upload your photo, touch camera icon on screen. Then popup window will show up and you can choose between camera and album. If you choose camera, you can take a picture, and if you choose album, you can select one image in the album.
After you take picture or select image in album, the image will display at screen. You can see small red button at the right corner of top. If you want to cancel image, just click this button. You can also change image by touching any spot of image.
Now it's time to put in text. When you type text, the window will get bigger by the length of text. You can see post button by scrolling up the screen.
Below text box, sns buttons are positioned. Press the buttons of sns where you want to send your post. Then authentication will be processed. After the process succeeds, the color of the button will be activated. The authentication keep alive even after rerunning the app. You don't have to repeat the authentication process every time you run this app. It is very convenient. Please be aware that Facebook android app should be preinstalled if you want to use facebook.
Finally, post your writing by clicking post button. Loading bar will show, and when sending finishes, the bar will disappear and you can see a message saying posted successfully. If Google Plus button is activated, you will see additional edit window. You can add another image or video here. Now you can see your post at the websites of sns.
There are two types of post. One is just sending text message and the other is sending text message and image all together. SNS Manager Plus doesn't not support video.
If you want to upload your photo, touch camera icon on screen. Then popup window will show up and you can choose between camera and album. If you choose camera, you can take a picture, and if you choose album, you can select one image in the album.
After you take picture or select image in album, the image will display at screen. You can see small red button at the right corner of top. If you want to cancel image, just click this button. You can also change image by touching any spot of image.
Now it's time to put in text. When you type text, the window will get bigger by the length of text. You can see post button by scrolling up the screen.
Below text box, sns buttons are positioned. Press the buttons of sns where you want to send your post. Then authentication will be processed. After the process succeeds, the color of the button will be activated. The authentication keep alive even after rerunning the app. You don't have to repeat the authentication process every time you run this app. It is very convenient. Please be aware that Facebook android app should be preinstalled if you want to use facebook.
<Google Plus activated>
<Google Plus inactivated>
Finally, post your writing by clicking post button. Loading bar will show, and when sending finishes, the bar will disappear and you can see a message saying posted successfully. If Google Plus button is activated, you will see additional edit window. You can add another image or video here. Now you can see your post at the websites of sns.
SNS Manager Plus 매뉴얼
미투데이, 트위터, 페이스북, 구글플러스 계정 관리하기 귀찮으시죠? SNS Manager Plus로 편리하게 관리하세요. 한 번만 클릭하면 모든 SNS에 사진과 글이 올라갑니다.
글은 두 가지 유형으로 올릴 수 있습니다. 첫 번째 유형은 글만 전송하는 것이고 두 번째 유형은 글과 사진을 함께 전송하는 것입니다. 여기서 동영상은 아직 지원하지 않습니다.
사진을 올리기를 원하는 경우 화면에서 카메라 아이콘을 터치합니다. 그러면 카메라와 앨범에서 선택하라는 팝업창이 뜹니다. 카메라를 선택하면 직접 사진을 찍을 수 있고 앨범을 선택하면 기존에 촬영한 사진 중에서 하나를 선택할 수 있습니다.
사진을 찍거나 앨범에서 선택하면 화면에 이미지가 표시됩니다. 이미지의 좌측 상단을 보면 빨간색 엑스 버튼이 보입니다. 사진을 취소하기를 원하는 경우 이 버튼을 클릭하면 됩니다. 사진의 임의의 부분을 누르면 다시 카메라와 앨범 팝업창이 뜹니다. 이런 방식으로 사진을 변경할 수도 있습니다.
이제 글을 입력할 차례입니다. 글을 입력하면 길이에 따라 창의 높이가 늘어납니다. 화면을 위로 스크롤하면 올리기 버튼을 볼 수 있습니다.
글 아래에는 SNS 버튼들이 있습니다. 글을 올리기를 원하는 곳의 버튼을 누르면 인증 처리가 실행됩니다. 인증에 성공하면 해당 버튼의 색상이 활성화됩니다. 한 번 인증하면 앱을 종료하고 다시 실행되어도 계속 인증 상태가 유지됩니다. 앱을 실행할 때마다 매번 인증할 필요가 없어 편리합니다. 여기서 페이스북 버튼의 경우 페이스북 안드로이드 앱이 미리 설치되어 있어야 원활하게 작동합니다.
위의 모든 과정을 마치면 올리기 버튼을 클릭하여 글을 올립니다. 전송하는 동안 로딩바가 돌고 전송이 끝나면 로딩바가 사라지며 글이 성공적으로 전송되었다는 메시지가 뜹니다. 구글 플러스 SNS 버튼이 활성화되어 있는 경우 별도의 편집창이 뜹니다. 여기서 사진이나 동영상을 추가할 수 있습니다. 글을 올리고 난 후 브라우저를 실행하여 SNS의 웹사이트에 접속하면 방금 글과 사진이 정상적으로 올려졌다는 것을 확인할 수 있습니다.
글은 두 가지 유형으로 올릴 수 있습니다. 첫 번째 유형은 글만 전송하는 것이고 두 번째 유형은 글과 사진을 함께 전송하는 것입니다. 여기서 동영상은 아직 지원하지 않습니다.
사진을 올리기를 원하는 경우 화면에서 카메라 아이콘을 터치합니다. 그러면 카메라와 앨범에서 선택하라는 팝업창이 뜹니다. 카메라를 선택하면 직접 사진을 찍을 수 있고 앨범을 선택하면 기존에 촬영한 사진 중에서 하나를 선택할 수 있습니다.
사진을 찍거나 앨범에서 선택하면 화면에 이미지가 표시됩니다. 이미지의 좌측 상단을 보면 빨간색 엑스 버튼이 보입니다. 사진을 취소하기를 원하는 경우 이 버튼을 클릭하면 됩니다. 사진의 임의의 부분을 누르면 다시 카메라와 앨범 팝업창이 뜹니다. 이런 방식으로 사진을 변경할 수도 있습니다.
이제 글을 입력할 차례입니다. 글을 입력하면 길이에 따라 창의 높이가 늘어납니다. 화면을 위로 스크롤하면 올리기 버튼을 볼 수 있습니다.
글 아래에는 SNS 버튼들이 있습니다. 글을 올리기를 원하는 곳의 버튼을 누르면 인증 처리가 실행됩니다. 인증에 성공하면 해당 버튼의 색상이 활성화됩니다. 한 번 인증하면 앱을 종료하고 다시 실행되어도 계속 인증 상태가 유지됩니다. 앱을 실행할 때마다 매번 인증할 필요가 없어 편리합니다. 여기서 페이스북 버튼의 경우 페이스북 안드로이드 앱이 미리 설치되어 있어야 원활하게 작동합니다.
<인증 해제 상태>
<인증 승인 상태>
위의 모든 과정을 마치면 올리기 버튼을 클릭하여 글을 올립니다. 전송하는 동안 로딩바가 돌고 전송이 끝나면 로딩바가 사라지며 글이 성공적으로 전송되었다는 메시지가 뜹니다. 구글 플러스 SNS 버튼이 활성화되어 있는 경우 별도의 편집창이 뜹니다. 여기서 사진이나 동영상을 추가할 수 있습니다. 글을 올리고 난 후 브라우저를 실행하여 SNS의 웹사이트에 접속하면 방금 글과 사진이 정상적으로 올려졌다는 것을 확인할 수 있습니다.
2013년 6월 12일 수요일
how to get hash of debug key for facebook auth
Type the following in the terminal, Window 7.
keytool -exportcert -alias androiddebugkey -keystore C:\Users\user
\.android\debug.keystore | C:\OpenSSL\bin\openssl sha -binary | C:\OpenSSL\bin\openssl base64 -out base64_2
Now a file has created in the default path of command(for example, C:\Users\user>). You can open the file to get hash key.
2013년 4월 16일 화요일
2013년 4월 10일 수요일
2013년 3월 28일 목요일
2013년 3월 26일 화요일
specified child already has parent
this is incorrect:
ImageView imageView = new ImageView(this);
for(int i=0; i<5; i++) {
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}
this is correct:
for(int i=0; i<5; i++) {
ImageView imageView = new ImageView(this);
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}
ImageView imageView = new ImageView(this);
for(int i=0; i<5; i++) {
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}
this is correct:
for(int i=0; i<5; i++) {
ImageView imageView = new ImageView(this);
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}
2013년 3월 24일 일요일
NO USB Debugging Mode in 4.2 ?
Open Settings, then go to phone details (where u can see kernel, Android-version etc) then just tap your Build number "JOP40C" 7 times !
2013년 3월 19일 화요일
convert android project to aspectj project
click right button of mouse on android project name in package explorer. Then choose "Configure" and then "convert to aspectj project".
2013년 3월 13일 수요일
2013년 3월 11일 월요일
how to get key hash for facebook sdk in Ubuntu
type the following command on terminal.
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
password is android.
2013년 3월 10일 일요일
2013년 3월 8일 금요일
how to make eclipse icon on launcher on Ubuntu 12.04 with android adt bundle
How to install Eclipse 4.2 on Ubuntu 12.04
Because Eclipse packages in Ubuntu are out of date. If we want to install last releases we are going to do it manually. You can just download the tar.gz file from eclipse.org.
1) Download Eclipse. I got
eclipse-jee-juno-SR1-linux-gtk.tar.gz
2) Extract it by executing a command line
tar -xzf eclipse-jee-juno-SR1-linux-gtk.tar.gz
Or with Archive Manager extraction.
3) Move extracted eclipse folder to
/opt/ folder
mv eclipse /opt/
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
4) Create an eclipse executable in your user path
sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
Create a file named
eclipse
in /usr/bin/
with your preferred editor (nano
, gedit
, vi
...)
Copy this into it
#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*
And save the file
5) Create a Gnome menu item
Create a file named
eclipse.desktop
in /usr/share/applications/
with your preferred editor (nano
,gedit
, vi
...)
Copy this into it
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
And save the file
6) Launch Eclipse
/opt/eclipse/eclipse -clean &
7) Now you can Lock Eclipse to the launcher bar by clicking right button on Lock to Laucher
2013년 3월 7일 목요일
2013년 3월 6일 수요일
2013년 3월 5일 화요일
2013년 2월 28일 목요일
how to make facebook api sample project
1. Download facebook android api.
2. Extract the downloaded file to a proper folder.
3. Make Android application project using facebook folder.
4. Import sample project Hackbook using existing projects into workspace. Do not use existing android code into workspace.
5. Add facebook library to project.
6. Fix project properties
2. Extract the downloaded file to a proper folder.
3. Make Android application project using facebook folder.
4. Import sample project Hackbook using existing projects into workspace. Do not use existing android code into workspace.
5. Add facebook library to project.
6. Fix project properties
2013년 2월 27일 수요일
how to deal char
1. get char code: cast (int) for char
char = 'ㅎ';
int charCode = (int) char;
2. compare two chars:
char char1='ㄹ';
char char2='ㅌ';
if(char == char2) //do something
3. 'ㅎ' is not same as ininial sound 'ㅎ' of '하나';
char = 'ㅎ';
int charCode = (int) char;
2. compare two chars:
char char1='ㄹ';
char char2='ㅌ';
if(char == char2) //do something
3. 'ㅎ' is not same as ininial sound 'ㅎ' of '하나';
get initial sound of Korean String
private char getChosung(String s) {
// typo스트링의 글자수 만큼 list에 담아둡니다.
for (int i = 0; i < s.length(); i++) {
char comVal = (char) (s.charAt(i) - 0xAC00);
if (comVal >= 0 && comVal <= 11172) {
// 한글일경우
// 초성만 입력 했을 시엔 초성은 무시해서 List에 추가합니다.
char uniVal = (char) comVal;
// 유니코드 표에 맞추어 초성 중성 종성을 분리합니다..
char cho = (char) ((((uniVal - (uniVal % 28)) / 28) / 21) + 0x1100);
if (cho != 4519) {
return cho;
}
} else {
return 'ㄱ';
}
}
return 'ㄱ';
}
if animation and scrolllistener collide
add scrolllistener when animation is finished(onAnimationEnd method).
2013년 2월 26일 화요일
get city name without open api
private void getCityName(double mLat, double mLong) {
String result = null;
Geocoder mGeoCoder = new Geocoder(this, Locale.KOREA);
try {
List<Address> addrs = mGeoCoder.getFromLocation(mLat, mLong, 1);
Address address = addrs.get(0);
result = address.getLocality();
} catch (IOException e) {
}
Toast.makeText(this, result, Toast.LENGTH_LONG).show();
}
slide up animation when start activity
Intent intent = new Intent(this, LoginActivity.class);
ActivityOptions options = ActivityOptions.makeCustomAnimation(this,
R.animator.slide_up, R.animator.fade_in);
startActivity(intent, options.toBundle());
-------slide_up.xml-------------------
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromYDelta="100%"
android:toYDelta="0%" />
---------fade_in.xml----------------------
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.9"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
!! If put 0 in the place of "R.animator.fade_in" in ActivityOptions.makeCustomAnimation method, the background activity will turn black.
android how to resize layout when softkeyboard goes up
<activity
android:name="com.example.keyboardviewtest2.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:windowSoftInputMode="adjustResize"
>
get shared preference from other app
App 1:
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext(
"com.example.sharedpreferencehosttest",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences.Editor editor = otherAppsContext
.getSharedPreferences(
"PREFS_FILE",
Context.CONTEXT_IGNORE_SECURITY).edit();
editor.putString("sharedpreferencehosttest", "sogi");
editor.commit();
App 2:
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext(
"com.example.sharedpreferencehosttest",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences sharedPreferences = otherAppsContext
.getSharedPreferences("PREFS_FILE", Context.CONTEXT_IGNORE_SECURITY);
Toast.makeText(
this,
sharedPreferences.getString("sharedpreferencehosttest",
"can not get value"), Toast.LENGTH_LONG).show();
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext(
"com.example.sharedpreferencehosttest",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences.Editor editor = otherAppsContext
.getSharedPreferences(
"PREFS_FILE",
Context.CONTEXT_IGNORE_SECURITY).edit();
editor.putString("sharedpreferencehosttest", "sogi");
editor.commit();
App 2:
Context otherAppsContext = null;
try {
otherAppsContext = createPackageContext(
"com.example.sharedpreferencehosttest",
Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
}
SharedPreferences sharedPreferences = otherAppsContext
.getSharedPreferences("PREFS_FILE", Context.CONTEXT_IGNORE_SECURITY);
Toast.makeText(
this,
sharedPreferences.getString("sharedpreferencehosttest",
"can not get value"), Toast.LENGTH_LONG).show();
2013년 2월 25일 월요일
android webview detect scroll
make custom webview class extending webview, and override onscrollchanged method.
webview loadurl open in a browser??
webView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return (false);
}
});
ObjectAnimation ran just one time
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
v.setRotationY(0);
}
});
2013년 2월 24일 일요일
listview adapter.remove unsupportedoperationexception
Check if you use string array, not arraylist. String array doesn't have remove() method, so when you try to use remove() method, it gives UnsupportedOperationException. So change string array to arraylist.
String[] array = {"a","b","c","d","e","f","g"};
ArrayList<String> lst = new ArrayList<String>();
lst.addAll(Arrays.asList(array));
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, lst);
2013년 2월 22일 금요일
ERROR_NOT_MARKET_MANAGED
Wait for your app to show up on Google Play market after you published it. Once it appears on market, maybe after several hours, you will get "Licensed" response.
2013년 2월 21일 목요일
if downloading android full source keeps fails
use the following two command instead of "repo sync".
$ sudo sysctl -w net.ipv4.tcp_window_scaling=0
$ repo sync -j1
2013년 2월 20일 수요일
2013년 2월 19일 화요일
how to get app installed date
long installed = context.getPackageManager().getPackageInfo("package.name", 0).firstInstallTime;
listview layout_weight not working
Check if layout_width of ListView tag is not "wrap_content".
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
2013년 2월 17일 일요일
how to download android full source 4
I am downloading android full source now following the steps on the android website.
http://source.android.com/source/downloading.html
At first, it didn't work. So I moved to the root folder and refollowed the steps. And It W
ORKED!!!
http://source.android.com/source/downloading.html
At first, it didn't work. So I moved to the root folder and refollowed the steps. And It W
ORKED!!!
how to download android full source 3 - jdk, curl, python, and git
To download android full source, four programs should be installed in advance: cUrl, Python, Git, Jdk. Python is already installed on Ubuntu 12.04 Lts. So I had to install cUrl, Git, and Jdk. It is easy to install cUrl and Git. I just had to type "sudo apt-get install curl" and "sudo apt-get install git" on terminal prompt.
I installed Oracle Sun Java jdk, not openjdk. I heared that sun jdk is better than openjdk. I installed jdk referencing the following blog.
http://www.printandweb.ca/2012/04/manually-install-oracle-jdk-6-for.html
I installed Oracle Sun Java jdk, not openjdk. I heared that sun jdk is better than openjdk. I installed jdk referencing the following blog.
http://www.printandweb.ca/2012/04/manually-install-oracle-jdk-6-for.html
how to download android full source 2 - language input on Ubuntu
After installed Ubuntu, an error message about language, Korean, showed up. I installed necessary packages about it. But I couldn't input Korean. I restarted Ubuntu and added Korean input on IBus setting. Then I could enter Korean.
I can change language input pressing Ctrl and Space together.
I can change language input pressing Ctrl and Space together.
how to download android full source 1 - ubuntu
Android full source can be downloaded on Mac os or Linux, not Window. I use Window 7 like many guys.So I installed Ubuntu 12.04 lts, the popular linux version using Wubi, Ubuntu window installer. I chose 12.04 lts version because it is stable.
Ubuntu download url: http://www.ubuntu.com/download
Ubuntu download url: http://www.ubuntu.com/download
2013년 1월 29일 화요일
2013년 1월 24일 목요일
2013년 1월 23일 수요일
2013년 1월 22일 화요일
android listview scrollto certain position(top)
final ListView listView = (ListView) findViewById(R.id.myListView);
Collections.addAll(values, values2);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
listView.post( new Runnable() {
int scrollOffset = -2;
int visibleChildCount = (listView.getLastVisiblePosition() - listView.getFirstVisiblePosition()) + 1; // row count visible on screen
@Override
public void run() {
listView.smoothScrollToPosition(visibleChildCount + scrollOffset + wantedPosition);
}
});
}
2013년 1월 20일 일요일
custom seekbar design
seekbar_progress_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/progress_line" />
</clip>
</item>
</layer-list>
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/progress_bg" />
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8" />
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg"/>
</layer-list>
<SeekBar android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22.5dp"
android:layout_marginRight="22.5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/ams_tool_stroke_pointer"
/>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/progress_line" />
</clip>
</item>
</layer-list>
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/progress_bg" />
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8" />
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg"/>
</layer-list>
<SeekBar android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22.5dp"
android:layout_marginRight="22.5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/ams_tool_stroke_pointer"
/>
2013년 1월 18일 금요일
galasy nexus wifi hotspot not working on window 7
update wireless adapter driver at device manager in control panel.
2013년 1월 16일 수요일
convert array to arraylist
List myList = new ArrayList();
String[] myStringArray = new String[] {"Java", "is", "Cool"};
Collections.addAll(myList, myStringArray);
String[] myStringArray = new String[] {"Java", "is", "Cool"};
Collections.addAll(myList, myStringArray);
two things you should be careful when you are creating layout dynmically
If creating view dynamically doesn't work, inflate xml file instead.
if layoutMargin doesn't work, use padding
if layoutMargin doesn't work, use padding
2013년 1월 13일 일요일
get width and height of screen
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenWidth = displayMetrics.widthPixels;
int screenHeight = displayMetrics.heightPixels;
2013년 1월 12일 토요일
android image scaling, save on sdcard, read the file on sdcard
ImageView profileImage = (ImageView) findViewById(R.id.imageview);
Bitmap bitmap = AddProfileImageActivity.getInstance()
.getProfileBitmap();
// 서버 업로드용 이미지를 800*800으로 스케일링합니다.
Bitmap scaledImageForServer = Bitmap.createScaledBitmap(bitmap,
SCALED_WIDTH, SCALED_HEIGHT, true);
// 스케일된 비트맵을 파일로 저장합니다.
File sdcard = Environment.getExternalStorageDirectory();
String filePath = sdcard.getAbsolutePath() + "/test.png";
try {
FileOutputStream out = new FileOutputStream(filePath);
scaledImageForServer.compress(Bitmap.CompressFormat.PNG, 90,
out);
} catch (Exception e) {
e.printStackTrace();
}
Bitmap bitmapInSdcard = BitmapFactory.decodeFile(filePath);
profileImage.setImageBitmap(bitmapInSdcard);
2013년 1월 11일 금요일
convert inputstream to string
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
is.close();
return sb.toString();
}
2013년 1월 10일 목요일
show soft keyboard
use the following method onCreate() or somewhere.
private void showVirturalKeyboard(){
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
InputMethodManager m = (InputMethodManager) SearchActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(m != null){
// m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
}
}
}, 100);
}
피드 구독하기:
글 (Atom)