dialog - android open dialogue activity without opening main activity behind it -


IM is writing a program that provides a quick reply dialog upon receiving an SMS.

However, I is getting an unexpected result when I receive an SMS, the proper communication activity displays the correct phone number and message, but there is another activity behind it that is' default in my program 'Activity is (that is when I open my application, then it opens).

I do not want to let this other activity happen. Instant response is what the user was doing. And should reach the same.

'floating' activity:

  public square expands quick accountability activity {string mnm, mmssage; TextView mMainText; /** Called when the activity is first created. * / @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); SetContentView (R.layout.main); MMainText = (TextView) FindViewById (R.id.mainText); Try {intent i = getIntent (); Bundle Extras = IAA Accta (); MNumber = extras.getString ("theNumber"); MMessage = extras.getString ("theMessage"); This.setTitle ("Message:" + mNumber); MMainText.setText (mMessage); } Hold (exception e) {mMainText.setText (e.getMessage ()); }}  

}

call on activity onReiveive ()

  i = new intent of intent (reference, quick reply .class); I.putext ("theumber", mNumber); I.putext ("themessage", mMessage); I.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); Context.startActivity (i);  

Manifest:

  & lt; Apps Android: icon = "@drawable / icon" Android: label = "@ string / app_name" & gt; & Lt; Activity Android: name = ". QuickReply" Android: label = "@ string / app_name" Android: Theme = "@Android: Style / Theme.milog" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.intent.action.MAIN" /> & Lt; Category android: name = "android.intent.category.LAUNCHER" /> & Lt; / Intent-Filter & gt; & Lt; / Activity & gt; & Lt; Receiver Android: name = ".smsreceiver" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.provider.Telephony.SMS_RECEIVED" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt; & Lt; / Application & gt;  

The only way I found that works Definition of your activity in the manifest in:

  android: launchMode = "single instance"  

But after the dialog ends you will see your main / default activity Will have to launch again. Note: You will lose all the state from the previous launch, so it is less than the ideal solution.

Update:

You can also:

  Intent. FLAG_ACTIVITY_CLEAR_TASK  

Here's what I did:

  1. Open original / main activity
  2. From the service, above (the main sub- Launch Dialog Style Activity Using Bye Bye
  3. When the user dismisses the dialog, start again with an additional intent (IS_BACK), which is processed onCreate () and call:

    < P> moveTaskToBack (true);

This will put the task at the top and under the back of your main stack.


Comments