我想知道實際的鬧鐘應用程序如何在確切的時間彈出對話框,沒有任何活動在它的背景。如果你可以請看我的this帖子,我正在尋找的確切解決方案,但對這個問題的答案非常感謝。實際的鬧鐘應用程序是如何工作的?
代碼彈出
public void onCreate(Bundle savedinstance)
{
super.onCreate(savedinstance);
//alarmsound = MediaPlayer.create(this, R.raw.wewillrock);
alarmsound = new MediaPlayer();
try {
if(db.getAlarmCount()!=0)
{
Cursor alarmcursor = db.getAlarmdetails(this);
if(alarmcursor!=null)
{
alarmcursor.moveToFirst();
String alarmTonepath = alarmcursor.getString(alarmcursor.getColumnIndex(GinoClockDatabase.AL_RINGTONEPATH));
alarmsound.setDataSource(alarmTonepath);
alarmsound.prepare();
}
db.close();
}
db.close();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block0
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
alarmsound.start();
((Activity)Global.context).finish();
setContentView(R.layout.reminderpopupmessage);
settingViews();
}
private void settingViews() {
yes = (Button) findViewById(R.id.btnReminderyes);
no = (Button) findViewById(R.id.btnReminderno);
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.btnReminderyes:
alarmsound.stop();
Intent splashscreen = new Intent(ReminderPopupMessage.this,SplashScreen.class);
startActivity(splashscreen);
ReminderPopupMessage.this.finish();
break;
case R.id.btnReminderno:
alarmsound.stop();
ReminderPopupMessage.this.finish();
break;
}
}
我找了一個多月了這一解決方案,但未能找到解決方案。我想我已經問了超過5個關於這個報警功能的問題。 我希望我現在能得到答案。
感謝您的幫助球員。
創建您自己的彈出窗口,然後顯示它! – Carnal 2012-07-09 14:29:30
在您的xml文件中,將Activitiy設置爲對話框主題,以獲得如下的彈出窗口布局:android:theme =「@ android:style/Theme.Translucent.NoTitleBar」 – Carnal 2012-07-09 14:31:21
感謝您的評論。實際上,我的鬧鐘在彈出窗口中工作得很好。問題是當彈出顯示我得到上次使用的活動作爲背景..如果使用看到我的帖子,你會知道是什麼問題..請看我的問題 – GoCrazy 2012-07-09 14:34:38