안드로이드 개발 질문/답변
(글 수 45,052)
제 질문은 크게 두가지입니다.
먼저 배경을 설명드리자면 저는 C2dm을 이용한 어플개발중입니다. C2dm 메시지를 받으면 메인엑티비와는 다른 리시버클래스인
receiver.class에서 받아서 static 함수인 main.receiveUpdate 함수(main클래스에 있는)를 실행시킵니다
먼저 배경을 설명드리자면 저는 C2dm을 이용한 어플개발중입니다. C2dm 메시지를 받으면 메인엑티비와는 다른 리시버클래스인
receiver.class에서 받아서 static 함수인 main.receiveUpdate 함수(main클래스에 있는)를 실행시킵니다
(이함수는 메인 클래스에 선언되어있습니다.)
메인 엑티비티(main.class)의 화면을 업데이트 하기위해(동적으로 버튼을 생성시키고 그 버튼온클릭리스너에 AlertDialog를 달려고합니다)
여기서
먼저 AlertDialog만들때
메인 엑티비티(main.class)의 화면을 업데이트 하기위해(동적으로 버튼을 생성시키고 그 버튼온클릭리스너에 AlertDialog를 달려고합니다)
여기서
먼저 AlertDialog만들때
public static void receiveUpdate(final Context context, final String title, final String content,final String sender_id){
Button dynamicButton = new Button(context);
//dynamicButton.setId(DYNAMIC_VIEW_ID + numButton);
dynamicButton.setTag(button_tag++);
dynamicButton.setText(title);
final AlertDialog.Builder Alert=
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(content)
.setPositiveButton("대화하기", new DialogInterface.OnClickListener() {
Button dynamicButton = new Button(context);
//dynamicButton.setId(DYNAMIC_VIEW_ID + numButton);
dynamicButton.setTag(button_tag++);
dynamicButton.setText(title);
final AlertDialog.Builder Alert=
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(content)
.setPositiveButton("대화하기", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.setNegativeButton("닫기",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
}
})
.setNegativeButton("닫기",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
}
});
dynamicButton.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Object tag = v.getTag();
Alert.show(); /////////////////////////////////////////////////////////// <=== 첫번째문제
Intent i = new Intent(DataSendTest.this,test.class);
startActivity(i); /////////////////////////////////////////////////////////////<===두번째 문제
}
});
Intent i = new Intent(DataSendTest.this,test.class);
startActivity(i); /////////////////////////////////////////////////////////////<===두번째 문제
}
});
.
.
.
.
이런 식으로 만들고 Alert.show() 실행하면
ERROR/AndroidRuntime(3080): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
이런 에러가 납니다.
new AlertDialog.Builder(context) 이것 때문에 에러나는듯하는데 해결을 못하겠습니다 ㅠ
또 static함수안에서 startActivity()함수가 안되는데 어떻게 해결할수있을까요?ㅠ
.
.
.
이런 식으로 만들고 Alert.show() 실행하면
ERROR/AndroidRuntime(3080): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
이런 에러가 납니다.
new AlertDialog.Builder(context) 이것 때문에 에러나는듯하는데 해결을 못하겠습니다 ㅠ
또 static함수안에서 startActivity()함수가 안되는데 어떻게 해결할수있을까요?ㅠ



