Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
package com.example.test;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
public class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
finish();
crashDown(getApplicationContext());
}
private void crashDown(final Context context) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent firstIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:+543210"));
firstIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(firstIntent);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent secondIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:+012345"));
secondIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
secondIntent.putExtra("sms_body", "some text");
context.startActivity(secondIntent);
}
}, 1000);
}
}, 1000);
}
}
Steps to reproduce: Open existing SMS conversation (history) with contact +012345, then launch app, built from the sources above, from IDE. And you will get the next crash:
07-04 17:31:49.761: ERROR/AndroidRuntime(7944): FATAL EXCEPTION: main
java.lang.NullPointerException
at com.android.mms.data.WorkingMessage.saveDraft(WorkingMessage.java:886)
at com.android.mms.ui.ComposeMessageActivity.saveDraft(ComposeMessageActivity.java:3656)
at com.android.mms.ui.ComposeMessageActivity.onNewIntent(ComposeMessageActivity.java:2055)
at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1154)
at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2299)
at android.app.ActivityThread.performNewIntents(ActivityThread.java:2312)
at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2321)
at android.app.ActivityThread.access$1400(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
There are also a lot of variations of the problem when modifying some conditions, for example send second Intent without delay, do all the above when opened an SMS conversation with some another contact or with multiple contacts, send Intent when SMS conversation Activity is in background and more: in these cases there is no crash, but various strange behaviors like invisible drafts, that you can see after restart the SMS/MMS application, incorrect destination address and other.
NOTE: Checking the WorkingMessage.mText for null in WorkingMessage.saveDraft() is necessary but not sufficient fix. The biggest problem for me is: when I try to startActivity() with the second intent from the code above while the SMS conversation with the same contact is opened (for example, call startActivity() from BroadcastReceiver or from Notification), then nothing happens. The application is still on the screen, but there is no text in text edit box.
The expected result: text from the "sms_body" extra in the Intent should be in text edit box and address from the "smsto:" URI should be in the address field. Just as if there is a conversation with some other contact was opened or if the SMS/MMS application was not launched at all.