2014-01-23 28 views
-1

我的代碼是否阻止我的應用程序打開?沒有錯誤,但它不是開放的。或者是有問題的分裂字符串導致衝突的地方?防止應用程序打開的代碼?

Mainactivity:

package com.pk.code; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.widget.TextView; 

public class MainActivity extends Activity { 

    TextView smsText;@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     smsText = (TextView) findViewById(R.id.smsText); 

     Bundle extra = getIntent().getExtras(); 
     if (extra != null) { 
      String SMSText = extra.get("sms").toString(); 
      String[] splitted = SMSText.split("-"); 
      if (splitted.length > 1 && splitted.length < 4) { 
       smsText.setText(" " + splitted[0] + "," + " " + splitted[1]); 
      } else { 
       smsText.setText(SMSText); 


      } 
     } 
    } 


    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 
} 
+0

你打算如何打開它,究竟發生了什麼? –

+0

logcat日誌是什麼? – taytay

回答

0

最有可能在extra.get問題( 「SMS」),則返回null。檢查你的logcat並在崩潰後在這裏打印

相關問題