1- package com .nerdinand .smssender ;
1+ package com .nerdinand .smsgateway ;
22
33import android .app .Activity ;
44import android .app .PendingIntent ;
1212import android .telephony .SmsManager ;
1313import android .view .Menu ;
1414import android .view .MenuItem ;
15+ import android .view .View ;
16+ import android .widget .ScrollView ;
1517import android .widget .TextView ;
1618
1719import java .io .BufferedReader ;
@@ -26,15 +28,18 @@ public class MainActivity extends ActionBarActivity {
2628 private static final String SENT = "SMS_SENT" ;
2729 private static final String DELIVERED = "SMS_DELIVERED" ;
2830
31+ private TextView textTextView ;
32+ private ScrollView scrollView ;
33+
2934 private ServerSocket serverSocket ;
3035 private Handler updateConversationHandler ;
31- private TextView textTextView ;
3236 private Thread serverThread ;
37+ private static CommunicationThread communicationThread ;
3338 private SmsManager smsManager ;
3439
3540 private PendingIntent sentPendingIntent ;
3641 private PendingIntent deliveredPendingIntent ;
37- private static CommunicationThread communicationThread ;
42+
3843 private BroadcastReceiver sentBroadcastReceiver ;
3944 private BroadcastReceiver deliveredBroadcastReceiver ;
4045
@@ -44,6 +49,7 @@ protected void onCreate(Bundle savedInstanceState) {
4449 setContentView (R .layout .activity_main );
4550
4651 textTextView = (TextView ) findViewById (R .id .tv_text );
52+ scrollView = (ScrollView ) findViewById (R .id .sv_scroll_view );
4753
4854 if (savedInstanceState == null ) {
4955 createInitially ();
@@ -235,6 +241,12 @@ public UpdateUIThreadRunnable(String str) {
235241 @ Override
236242 public void run () {
237243 textTextView .setText (textTextView .getText ().toString () + msg + "\n " );
244+ scrollView .post (new Runnable () {
245+ @ Override
246+ public void run () {
247+ scrollView .fullScroll (View .FOCUS_DOWN );
248+ }
249+ });
238250 }
239251 }
240252}
0 commit comments