안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요, 완전 초보.. 입니다..;;
하다하다 도저히 안되는 게 있어서 들어왔습니다!!
검색해도 안나오더군요..
질문은 두가지입니다..
1. AlertDialog 사용시 오류..
- 다른 예제에서는 잘 되는데 왜 제가 짠 소스에서만 안되는 건지 모르겠습니다...
우선 android.app.Dialog와 android.app.AlertDialog는 import 한 상태에서,
showAADialog() 라는 함수 안에서
Dialog dialog = new AlertDialog.Builder(액티비티명.this)
.setView...
.....
.create();
를 해주었는데요, 계속 저 new 에서 에러가 납니다...
삼일째 이러고 있네요;;;
2. Reboot intent 사용
- 어떤 버튼을 눌렀을 때 reboot 을 시켜주고 싶은데요,
onPreferenceTreeClick 함수 안에서
Intent intent = new Intent();
intent.setAction(Intent.ACTION_REBOOT);
mContext.sendBroadcast(intent);
}
catch(Exception e)
{
return true;
}
이런 식으로 해줬는데 잘 안되더군요.. 물론 AndroidManifest 에는
<uses-permission android:name="android.permission.REBOOT" />
을 추가해주었습니다.
고수님들의 구원의 손길 기다려봅니다.
감사합니다.... ㅠ
하다하다 도저히 안되는 게 있어서 들어왔습니다!!
검색해도 안나오더군요..
질문은 두가지입니다..
1. AlertDialog 사용시 오류..
- 다른 예제에서는 잘 되는데 왜 제가 짠 소스에서만 안되는 건지 모르겠습니다...
우선 android.app.Dialog와 android.app.AlertDialog는 import 한 상태에서,
showAADialog() 라는 함수 안에서
Dialog dialog = new AlertDialog.Builder(액티비티명.this)
.setView...
.....
.create();
를 해주었는데요, 계속 저 new 에서 에러가 납니다...
삼일째 이러고 있네요;;;
2. Reboot intent 사용
- 어떤 버튼을 눌렀을 때 reboot 을 시켜주고 싶은데요,
onPreferenceTreeClick 함수 안에서
Intent intent = new Intent();
intent.setAction(Intent.ACTION_REBOOT);
mContext.sendBroadcast(intent);
}
catch(Exception e)
{
return true;
}
이런 식으로 해줬는데 잘 안되더군요.. 물론 AndroidManifest 에는
<uses-permission android:name="android.permission.REBOOT" />
을 추가해주었습니다.
고수님들의 구원의 손길 기다려봅니다.
감사합니다.... ㅠ
2010.11.08 11:50:50
리붓은 일반 어플에선 못합니다
public static final String ACTION_REBOOT
Since: API Level 1
Broadcast Action: Have the device reboot. This is only for use by system code.
This is a protected intent that can only be sent by the system.
Constant Value: "android.intent.action.REBOOT"




constructor의 return type이 잘못된 것 같네요.
Dialog dialog = new AlertDialog.Builder(액티비티명.this) 에서
dialog의 class type을 Dialog가 아니라 AlertDialog.Builder로 해보세요.
ex) AlertDialog.Builder dialog = new AlertDialog.Builder(액티비티명.this)