问题
I want to load an activity from the BroadcastReceiver
onReceive
method.
I have 2 activities, one is the main and the second I created.
I want to load the second activity from onReceive
but it's loading the main activity and I don't know why..
This is the intent on onReceive()
:
Intent i = new Intent(context, BTNotifierWarning.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
this is the BTNotifierWarning class:
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
}
}
and this is the warning xml layout:
<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" >
why it's happening?
Thanks!
来源:https://stackoverflow.com/questions/17906466/how-to-load-activity-from-broadcastreceiver-onreceive