我是初学者。每当我尝试启动我的Android应用程序,它显示一个错误unfortunately my app has been stopped
。现在让我具体说明一下,我创建了一个pushbots应用程序来获取通知,并通过将其转换为字符串在textview上显示它。当通知到达时,它会很好地工作,当我点击通知时,它会在屏幕上显示字符串,但不会在启动它时显示。我之前问过一个关于这个问题的问题,之前,deadfish说可能会发生这种情况,因为我的bundle是null,所以我尽我所能地为显示字符串的textview提供了一个临时字符串。但它仍然显示错误。我会在启动我的应用程序时向您展示logcat。我认为空包是没有问题的启动我的Android应用程序显示错误日志猫没有帮助?
08-16 08:58:06.868 13447-13454/com.bluestacks.chartapp I/jdwp﹕ Ignoring second debugger -- accepting and dropping
公共类MainActivity扩展ActionBarActivity {
public static final String TAG = MainActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Pushbots.sharedInstance().init(this);
Intent intent = getIntent();
//log the message in JSON format
Log.i(TAG, "Received message >> " + intent.getExtras().toString());
//Retrieve message and extra
String message = intent.getExtras().getString("message");
TextView t1 = (TextView)findViewById(R.id.textView);
if(message!=null) {
t1.setText(message);
}
else
{
t1.setText("null");
}
Bundle extras = intent.getExtras();
String bigText = null;
TextView t2 = (TextView) findViewById(R.id.textView2);
if (extras != null && extras.containsKey("bigText")) {
bigText = extras.getString("bigText");
t2.setText(bigText);
}
else{
t2.setText("null");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
当应用程序崩溃时,从logcat发布一个完整的堆栈跟踪。 – Karakuri
String message = intent.getExtras()。getString(“message”); intent可以为null请确保在试图获得额外的 –