본문 바로가기

안드로이드

안드로이드 화면 잠금, 투명 액티비티

액티비티 투명 만들기

<activity

            android:name="com.example.lockedscreen.activity.PopActivity"

            android:label="@string/app_name" 

            android:theme="@android:style/Theme.Translucent">

* 잠금화면 위에 액티비티 띄울떄 투명을 적용하면, 잠금 화면은 보이지 않는다.


----------------------------------------------------------------------------------------------------


Activity의 타이틀바 제거

menifest >> android:theme = "@android:style/Theme.NoTitleBar"
http://warmz.tistory.com/154


--------------------------------------------------------------------------------------------------------------------


화면 잠금 여부

KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);

if(backgroundMediaPlayer != null && !km.inKeyguardRestrictedInputMode()){

backgroundMediaPlayer.start();


MainActivity가 실행중인지 확인.

ActivityManager am = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);

List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(10);

ComponentName componentInfo = null;

for (RunningTaskInfo runningTaskInfo : taskInfo) {

if (runningTaskInfo.topActivity.getPackageName().equals(context.getPackageName())) {

componentInfo = runningTaskInfo.topActivity;

if (componentInfo.getClassName().equals("com.example.lockedscreen.MainActivity")){

// 실행중이라면, 해당 Activity를 다시 띄움

Intent i = new Intent(context, MainActivity.class);

i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);

context.startActivity(i);

return;

}

}

}



broadcastreceiver 에서 activity 띄우기

// 실행중이라면 Activity를 새로 시작한다.

Intent i = new Intent(context, PopActivity.class);

//i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);

context.startActivity(i);


--------------------------------------------------------------------------------------------------------------------


ListView의 아이템이 CheckBox를 가질때, ListView에 setOnItemClickListener나 setOnItemLongClickListener를 구현해되 정작 ListView가 클리되지 않는 현상이 발생한다.

이는 리스트뷰의 아이템이 가지는 체크박스가 포커스를 가져가기 때문이다.


해결방법은 체크박스의 focusable 속성을 false로 설정해주면 정상적으로 리스트뷰가 클릭되고, 체크박스도 클릭된다.


'안드로이드' 카테고리의 다른 글

하나의 Activity에서 여러개의 ViewPager사용시 문제  (0) 2014.06.12
device 인식 못할때  (0) 2014.02.03
안드로이드 웹앱 개발시 스크롤 문제  (0) 2014.01.21
안드로이드 어플 등록  (0) 2014.01.21
receiver  (0) 2014.01.16