views:

290

answers:

1

Im writing a program that offers a quick reply dialog upon receipt of an SMS.

However, I am getting an unexpected result. When I receieve an SMS, the appropriate dialog activity comes up displaying the correct phone number and message, however there is a second activity behind it that is the 'default' activity in my program (it is what opens when i launch my application)

I do not want this second activity to come up. The quick reply activity should come up by itself over top of whatever the user was doing before.

The 'floating' activity:

public class quickReply extends Activity {
String mNumber, mMessage;
TextView mMainText;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mMainText = (TextView)findViewById(R.id.mainText);

    try{
        Intent i = getIntent();
        Bundle extras = i.getExtras();

        mNumber = extras.getString("theNumber");
        mMessage = extras.getString("theMessage");
         this.setTitle("Message From:" + mNumber);
         mMainText.setText(mMessage);


    } catch(Exception e) {
        mMainText.setText(e.getMessage());
    }      

}

}

The call to the activity inside an onReceive()

        Intent i = new Intent(context, quickReply.class);
    i.putExtra("theNumber", mNumber);
    i.putExtra("theMessage", mMessage);
    i.setFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);

The Manifest:

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".quickReply"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Dialog"
              >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
       <receiver android:name=".SmsReceiver"> 
        <intent-filter> 
            <action android:name=
                "android.provider.Telephony.SMS_RECEIVED" /> 
        </intent-filter> 
    </receiver>

</application>

A: 

You only have one activity.

CommonsWare
my bad, should have been more clear. it wasnt a second activity but rather a second instance of the same activity. however it happened it seems to have fixed itself.
jwheels