मैं एक प्रोग्राम लिख रहा हूं जो एक एसएमएस प्राप्त होने पर त्वरित उत्तर संवाद प्रदान करता है।एंड्रॉइड ओपन डायलॉग गतिविधि इसके पीछे मुख्य गतिविधि खोलने के बिना
हालांकि, मुझे एक अप्रत्याशित परिणाम मिल रहा है। जब मुझे एक एसएमएस प्राप्त होता है, तो उपयुक्त संवाद गतिविधि सही फोन नंबर और संदेश प्रदर्शित करती है, हालांकि इसके पीछे दूसरी गतिविधि है जो कि मेरे प्रोग्राम में 'डिफ़ॉल्ट' गतिविधि है (जब मैं अपना एप्लिकेशन लॉन्च करता हूं तो यह खुलता है)
मैं नहीं चाहता कि यह दूसरी गतिविधि आ जाए। जो भी उपयोगकर्ता पहले कर रहा था उसके शीर्ष पर त्वरित उत्तर गतिविधि स्वयं ही आनी चाहिए।
'चल' गतिविधि:
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());
}
}
}
एक 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);
मैनिफ़ेस्ट:
<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>