Activity Stack 제어

2011. 10. 21. 10:38
Android에서는 화면(Activity)가 새로 열릴 때마다
쌓도록 되어있고 뒤로(Back) 버튼을 누르면 현재 Activity를 제거 하여
History를 관리한다.

그런데 때때로 로그인 등 세션을 날리고 새로 하고 싶을 때
쌓여있는 Activity들을 날리고 싶을 때에는
Intent를 사용한다.

Intent intent = new Intent(Main.this, Sub.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);


Intent.FLAG_ACTIVITY_NO_HISTORY 는 호출하는 Activity를 Stack에 쌓지 않는다
따라서 여러화면을 거치다 Back버튼을 눌렀을 때 Sub.class는 나타나지 않는다.

쌓인 History를 모두 날릴 때에는
Intent.FLAG_ACTIVITY_CLEAR_TOP 이다.
Activity를 호출하면서 쌓여있던 Stack을 초기화 시킨다.

더 자세한 것은 FLAG_ACTIVITY를 찾아볼 것.
두개 이상도 사용가능 ^^
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP)
728x90
늘 궁금했언  두개이상의 Table을 어떻게 관리할까의 예제를 찾았다.

여기가 바로 그 링크다.


http://code.google.com/p/and-bookworm/source/browse/trunk/src/com/totsp/bookworm/data/dao/BookDAO.java


Source path:  svn trunksrccomtotspbookwormdatadaoBookDAO.java 
728x90
원인은 모르겠다.
새로 받아서 깔아보고 뭐 다 해봤는데도 계속 못찾는다는 메세지가 보였다.

결국 이클립스에서
"Help" -> "Check for uppdates"
android 관련 update를 하고 나니 해결이 됨. ㅡㅡ;
728x90
책에서는 그냥 layout_weight로 비율을 맞춘다고 했는데
정확히 어떻게 줘야 하냐면

모든 가로폭을 관장하는 View를
layout_width=0
layout_weight=n

ex) 두개의 TextView를 2:8로 놓으려면
<LinearLayout
    layout_width=match_parent
    layout_height=wrap_content
>
<TextView
    layout_width="0"
    layout_weight="2"
    layout_height="wrap_content"/>
<TextView
    layout_width="0"
    layout_weight="8"
    layout_height="wrap_content"/>
</LinearLayout>

 로 주면 딱 비율이 맞는다.
굳이 10을 기준으로 하지 않아도 되지만
여러 Layout 반복되므로 계산하기 편하게 기준되는 수를 모든 화면에 동일하게 적용하는 게 좋다.

물론 0.5: 9.5 도 그대로 주면 된다.
layout_weight="0.5" 와 같이
728x90

2.1에서 잘 작동했던 restartpackage.
LogOut으로 썼는데 2.2에서는 사용할 수 없다.
근데 구글에는 같은 메소드가 다른이름으로 존재한다.

Google force closes packages in Android 2.2 (Froyo).
This happens over an internal API.
Method name is: forceStopPackage(String pkgName).


Class c = Class.forName("android.app.ActivityManagerNative");
Method getDefaultMethod = c.getMethod("getDefault");
getDefaultMethod.setAccessible(true);
Object nativeManager = getDefaultMethod.invoke(null);
c = nativeManager.getClass();
Method forceStopPackageMethod = c.getMethod("forceStopPackage", String.class);
forceStopPackageMethod.setAccessible(true);
forceStopPackageMethod.invoke(nativeManager, pkgName);
->
java.lang.SecurityException: Permission Denial: forceStopPackage() from pid=1965, uid=10075 requires android.permission.FORCE_STOP_PACKAGES

권한이 없댄다. 그래서
AndroidManifest.xml 에 추가했다.

그런데 이것역시 되지 않는다.
The only problem is that in order to use this method, you need the “android.permission.FORCE_STOP_PACKAGES” permission, and that permission requires a “signature” protectionLevel, so the system will not grant it unless the app is signed with the same signature as the system

해당 권한은 시그너쳐로 보호되고 있어서
시스템과 같은 사인이 아니면 권한을 얻을 수 없댄다.

된장....
728x90

간단히  App 을 만들 수 있는 Tool이라고 해서
다운받고 실행시키려고 했더니...

뭔가 입력하라고 한다.

입력 했더니 다음과 같이 뜨면서 기다리랜다.

728x90
한번 올려보려고 했더니... 돈내란다.

처음에는
이름
웹사이트주소
전화번호를 물어봐서
넣어줬더니

그 다음에는
$25를 내야 Developer로 등록 해 준단다

Register as a developer
Registration fee: $25.00
Your registration fee enables you to publish software in the market. The name and billing address used to register will bind you to the Android Market Developer Distribution Agreement. So make sure you double check!

Pay your registration fee with
Buy Now with Google Checkout



728x90
Tab 예제를 하면서
버튼이 눌러졌을 때 다른 tab으로 이동하게 하는것을 찾으려고 무진장 애를 썼으나...
찾기 힘들었다.

그런데 ㅋㅋㅋ 힌트를 얻은게 getParent()라는 게 있어서 한번 해 봤더니 되는군 ㅋㅋㅋ

onClick() event안에 넣으면 됨.

public void onClick(View view) {
                TabActivity tab = (TabActivity)getParent();
                TabHost tabHost = tab.getTabHost();
                tabHost.setCurrentTabByTag("targetTabName");//원하는 tabName
}

어딘가 다른 방법이 있다면 다른방법을 찾아봐야겠군 ^^;
728x90
Google Map View tutorial 을 배포 성공한 뒤에
overlayItem을 하나 더 추가했다.
(tutorial에서 그렇게 하라고 해서)

그런데 build도 문제없이 됐고 실행도 문제가 없는데
안드로이드 아이콘이 하나밖에 보이지 않는것이었다.

그래서 몇 번 재시도를 해봤는데도 똑같았다.

그러다 안드로이드 이미지를 클릭하면 맵을 zoom in/out하는 bar가 생기는데
거기에서 zoom out을 해봤더니 맵이 작아지면서 안보였던 android 이미지가 나타나더군...
예전 target찾을 때도 몇주를 헤맸었는데 ㅋㅋㅋ
화면을 잘 살펴봐야겠다.

728x90
Google Map View tutorial을 따라 하던중
Source코드를 다 하고 Error도 없는데
에뮬레이터를 가동시키자 위 에러와 함께 해당 App가 실행이 안되는 것이었다.

처름 프로젝트를 생성했을 때,
Google Apis를 target으로 지정했는데
프로젝트에서 maps.jar를 필요로 해서 해당 jar를 external jar에서 찾아서 build path에 추가했었다.
근데 그게 혼란을 준건가??

아무튼 추가한 build path에서 제거하고 다시 build를 한뒤
실행시켜보니 이제는 괜찮다.
728x90
BLOG main image
"그게 뭐 어쨌다는 거냐?" 늘 누가 나에게 나에대한 말을할 때면 이말을 기억해라. by nobang

카테고리

nobang이야기 (1933)
Life With Gopro (7)
Life With Mini (79)
Diary (971)
너 그거 아니(do you know) (162)
난 그래 (159)
Study (290)
Cloud (26)
Go lang (30)
Front-end (27)
Device (3)
MAC (1)
Spring framework (49)
Java (13)
English (39)
SOA (0)
Idioms (7)
모르는거 (5)
WriteEnglish (10)
Android (56)
속지말자 (10)
Project (34)
Poem (15)
Song (0)
Photo (113)
낙서장 (45)
일정 (0)
C.A.P.i (2)
PodCast (0)
nobang (27)
고한친구들 (4)
recieve (0)
History (0)
android_app (2)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :