如何从BroadcastReceiver onReceive加载活动

时间:2013-07-28 08:32:48

标签: android android-activity broadcastreceiver

我想从BroadcastReceiver onReceive方法加载活动。 我有2个活动,一个是主要的,另一个是我创建的。 我想从onReceive加载第二个活动,但它正在加载主要活动,我不知道为什么......

这是onReceive()的意图:

Intent i = new Intent(context, BTNotifierWarning.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);   

这是BTNotifierWarning类:

package com.btnotifier;

import android.app.Activity;
import android.os.Bundle;

public class BTNotifierWarning extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.warning);

        // TODO Auto-generated method stub
    }
}

这是警告xml布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".BTNotifierWarning" >

为什么会这样?

谢谢!

0 个答案:

没有答案