我有一个SMSReceiver
类,它扩展了BroadcastReceiver
. 收到短信后,我会创建通知。当它被点击时,我开始我自己的(不是主要的!)活动 - DialogActivity
:
Intent mIntent = new Intent(context, DialogActivity.class);
...
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent mPendingIntent =
PendingIntent.getActivity(
context,
mNotificationId,
mIntent,
0
);
mBuilder.setContentIntent(mPendingIntent);
但是,它始终显示在主要活动的顶部。因此,如果我finish
从调用DialogActivity
,则会显示主要活动。我怎么能避免呢?
DialogActivity
类如下所示:
public class DialogActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog); // android:theme="@android:style/Theme.Dialog"
Button dialogBtnNo = (Button) findViewById(R.id.dialog_btn_no);
dialogBtnNo.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
finish(); // close this activity
}
...
和清单文件:
<activity
android:name="my.package.DialogActivity"
android:label="@string/title_activity_dialog"
android:theme="@android:style/Theme.Dialog"
android:configChanges="keyboardHidden|orientation">
</activity>