我的代码是否阻止我的应用打开?没有错误,但它没有打开。或者是否存在导致冲突的拆分字符串的问题?
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)
很可能是extra.get(“sms”)中的问题,它返回null。检查你的logcat并在崩溃后在这里打印