안드로이드 개발 질문/답변
(글 수 45,052)
지금 몇일째 고생인데요..왜 전 안되는지 모르겠습니다..ㅜㅜ
일단 하고자 하는것은 아래 그림처럼 dialog가 독립적으로 뜨는것입니다.
그림1.
그런데 지금 현상은 아래 그림처럼 되는데요..
그림2.
그림2를 보면 메인 activity위에 뜨잖아요...이게 문젠데요..
전 그림1처럼 독립적으로 띄우고 싶거든요..
우선 소스를 보면
Manifest.xml
메세지를 받는 BroadcastReceiver를 상속받은 클래스에서는
그리고 dialog테마를 적용한 showMsg.class 입니다.
뭐가 문제일까요..ㅜㅜ
일단 하고자 하는것은 아래 그림처럼 dialog가 독립적으로 뜨는것입니다.
그림1.
그런데 지금 현상은 아래 그림처럼 되는데요..
그림2.
그림2를 보면 메인 activity위에 뜨잖아요...이게 문젠데요..
전 그림1처럼 독립적으로 띄우고 싶거든요..
우선 소스를 보면
Manifest.xml
<activity android:name="showMsg" android:theme="@android:style/Theme.Dialog" android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>메세지를 받는 BroadcastReceiver를 상속받은 클래스에서는
public class MsgReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
// 화면 깨우기
PushWakeLock.acquireCpuWakeLock(context);
Intent i = new Intent(context, showMsg.class);
Bundle b = new Bundle();
b.putString("title", title);
b.putString("msg", msg);
i.putExtras(b);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}그리고 dialog테마를 적용한 showMsg.class 입니다.
public class showMsg extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.notification_box);
//진동
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(500);
//화면 꺼짐을 방지
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
String title, msg;
Bundle bun = getIntent().getExtras();
title = bun.getString("title");
msg = bun.getString("msg");
TextView msgText = (TextView) findViewById(R.id.Msg);
msgText.setText(msg);
TextView titleText = (TextView) findViewById(R.id.Title);
titleText.setText(title);
Button closeBt = (Button) findViewById(R.id.notiClose);
closeBt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PushWakeLock.releaseCpuLock();
showMsg.this.finish();
}
});
Button excuteBt = (Button) findViewById(R.id.excute);
excuteBt.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent().setClassName(getPackageName(), getPackageName()+".Excute"));
PushWakeLock.releaseCpuLock();
showMsg.this.finish();
}
});
}
}뭐가 문제일까요..ㅜㅜ




첨부된 이미지 보시면 되요...